Skip to content

Fix #123: load NavigationCancelService's JS module lazily, not in the constructor - #124

Open
devel0peter wants to merge 1 commit into
mainfrom
fix/123-navigation-cancel-service-prerender
Open

Fix #123: load NavigationCancelService's JS module lazily, not in the constructor#124
devel0peter wants to merge 1 commit into
mainfrom
fix/123-navigation-cancel-service-prerender

Conversation

@devel0peter

Copy link
Copy Markdown
Contributor

Fixes #123.

NavigationCancelService started a JS interop import in its constructor field initialiser. The service is scoped and resolved during Blazor Server's static prerender pass, where JS interop throws — and since nothing awaits the stored task unless ProceedAsync later runs, the fault surfaced as a TaskScheduler.UnobservedTaskException logged at Error level on every page load of every consuming app, with a finalizer stack that identifies nothing (attributed in MagicSuite via a FirstChanceException stack capture — see MS-25810 / panoramicdata/MagicSuite#102).

The module is now imported on first use inside ProceedAsync: by the time a listener cancels a navigation the circuit is interactive, so the confirm-dialog behaviour is unchanged. PanoramicData.Blazor builds clean with the change.

MagicSuite currently carries a prerender-safe INavigationCancelService override registered after AddPanoramicDataBlazor(); that override will be removed once a version containing this fix is published and consumed.

🤖 Generated with Claude Code

… constructor

The constructor field initialiser started a JS interop import the moment
the scoped service was resolved. Under Blazor Server prerendering that is
during static rendering, where JS interop throws - and since nothing
awaits the stored task unless ProceedAsync later runs, the fault
surfaced as a TaskScheduler.UnobservedTaskException logged on every page
load of every consuming app, with a finalizer stack that identifies
nothing.

Import the module on first use inside ProceedAsync instead: by the time
a listener cancels a navigation the circuit is interactive, so the
confirm dialog behaviour is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NavigationCancelService starts JS interop in its constructor, causing UnobservedTaskException on every Blazor Server prerender

1 participant