Skip to content

Handle enhanced navigation fetch failures - #69504

Open
NanthiniMahalingam wants to merge 7 commits into
dotnet:mainfrom
NanthiniMahalingam:fix-51618
Open

NanthiniMahalingam wants to merge 7 commits into
dotnet:mainfrom
NanthiniMahalingam:fix-51618

Conversation

@NanthiniMahalingam

Copy link
Copy Markdown
Contributor

Bug Description

When Blazor enhanced navigation intercepted a link or form submission, it issued the navigation through fetch. If that request rejected—for example, because the server had stopped or the network was unavailable—the rejection occurred before response processing. As a result:

  • GET navigation could update the address bar but leave the old page visible.
  • The user received no indication that navigation had failed.
  • Enhanced form POST failures were not surfaced through the Blazor error UI.
  • A failed non-GET request could leave enhanced navigation marked as still loading.
  • Retrying POST requests as full-page loads would not be safe because POST operations may have side effects.

Description of code changes

In NavigationEnhancement.ts:

  • Enhanced form submissions now observe rejected navigation promises.
  • Failures are written to console.error.
  • The existing showErrorNotification() behavior displays #blazor-error-ui.

In performEnhancedPageLoad:

  • The request’s AbortController is retained locally.
  • Expected AbortError failures from superseded navigation are ignored.
  • Failed GET requests call the existing full-page fallback.
  • Failed non-GET requests:
    Aren’t automatically retried.
    Clear loading state only when they are still the current navigation.
    Invoke enhancedNavigationCompleted.
    Rethrow the original fetch error.

Tests

The new NavigationEnhancement.test.ts covers the failure, cancellation, form-error, and existing successful-navigation paths.

Output

Before changes

51618_GetNavigation_BeforeFix.mp4
51618_PostNavigation_BeforeFix.mp4

After changes

51618_GetNavigation_AfterFix.mp4
51618_PostNavigation_AfterFix.mp4

Fixes #51618

@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Sep 25, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Sep 25, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @NanthiniMahalingam. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@NanthiniMahalingam
NanthiniMahalingam marked this pull request as ready for review October 9, 2026 06:41
@NanthiniMahalingam
NanthiniMahalingam requested a review from a team as a code owner October 9, 2026 06:41
Copilot AI balanced review requested due to automatic review settings October 9, 2026 06:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Mixed-case GET forms can lose submitted values, and the browser-owned regression lacks required Selenium coverage.

2 open findings
What changed in this PR

Handles enhanced-navigation network failures while avoiding unsafe POST retries.

Changes:

  • Falls back to full-page navigation for failed GET requests.
  • Surfaces POST failures through the Blazor error UI and resets navigation state.
  • Adds Jest coverage for failure, cancellation, and success paths.
File Description
NavigationEnhancement.ts Adds failure handling and cancellation-aware cleanup.
NavigationEnhancement.test.ts Adds mocked navigation failure tests.

🧠 Review effort: Balanced

Comment thread src/Components/Web.JS/src/Services/NavigationEnhancement.ts
Comment thread src/Components/Web.JS/test/NavigationEnhancement.test.ts Outdated

This branch was successfully deployed

1 active (outdated) deployment
copilot-pat-pool — e93627d4 Deployed Sep 25, 2026 by dotnet-policy-service[bot] via pat_pool #1482
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhanced Navigation Silently Ignores Fetch Network Errors

3 participants