Skip to content

Commit f40458c

Browse files
committed
Added warning when enhanced navigation falls back to full page reload + test
1 parent c3fa2bb commit f40458c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Components/Web.JS/src/Services/NavigationEnhancement.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ function enhancedNavigationIsEnabledForForm(form: HTMLFormElement): boolean {
455455
function retryEnhancedNavAsFullPageLoad(internalDestinationHref: string) {
456456
// The ? trick here is the same workaround as described in #10839, and without it, the user
457457
// would not be able to use the back button afterwards.
458+
console.warn(`Enhanced navigation failed for destination ${internalDestinationHref}. Falling back to full page load.`);
458459
history.replaceState(null, '', internalDestinationHref + '?');
459460
location.replace(internalDestinationHref);
460461
}

src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ public void RefreshCanFallBackOnFullPageReload(string renderMode)
324324
Browser.Exists(By.Id("refresh-with-refresh")).Click();
325325
Browser.True(() => IsElementStale(initialRenderIdElement));
326326

327+
//Check if the warning about the fail were logged.
328+
var logs = Browser.GetBrowserLogs(LogLevel.Warning);
329+
Assert.Contains(logs, log => log.Message.Contains("Enhanced navigation failed for destination") && !log.Message.Contains("Error"));
330+
327331
var finalRenderIdElement = Browser.Exists(By.Id("render-id"));
328332
var finalRenderId = -1;
329333
Browser.True(() => int.TryParse(finalRenderIdElement.Text, out finalRenderId));

0 commit comments

Comments
 (0)