Description
When navigating away from a page containing a MapView while it is still initializing (specifically while the WebMap / basemap is loading), an unhandled promise rejection escapes into the browser console and can surface as an application error:
Uncaught (in promise) Error: dymaptic.GeoBlazor.Core.Exceptions.JavascriptException:
Aborted: Failed to load web map
at MapView.OnJavascriptError(...)
This happens because esri.WebMap#load() is aborted mid-flight, which GeoBlazor correctly detects as an AbortError, but then calls back into .NET via OnJavascriptError using invokeMethodAsync — at which point the MapView component has already been disposed. The resulting unhandled promise rejection bypasses ErrorBoundary entirely since it originates outside Blazor's render cycle.
Environment
- GeoBlazor Version: 4.4.4
- Blazor Hosting Model: WebAssembly
Steps to Reproduce
- Place a
MapView with a WebMap (portal item) on a page
- Navigate to that page
- Immediately navigate away before the map finishes loading
- Observe unhandled promise rejection in the browser console
Reproduced on Official Demo Site
This issue is reproducible on the GeoBlazor demo site itself, confirming it is not caused by
consumer code. Steps:
- Navigate to a map page on the GeoBlazor samples site
- Immediately navigate away before the map finishes loading
- Observe the same errors in the browser console:
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'reject')
at vb.start (LayerLayerViewInfo.js:5:2796)
Error building map view: TaskCanceledException_ctor_DefaultMessage
at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(...)
at dymaptic.GeoBlazor.Core.Components.Views.MapView.BuildMapView()
The #blazor-error-ui error banner is suppressed on the demo site (likely via CSS),
but the underlying unhandled exceptions are still visible in browser DevTools, confirming
the root cause is present regardless of the UI workaround.
The TypeError: Cannot read properties of null (reading 'reject') originates in the ESRI
SDK's own layer view promise chain being torn down mid-flight, suggesting the fix needs to
account for both GeoBlazor's .NET disposal guards and graceful handling of the ESRI SDK's
async teardown.
Clicking between https://samples.geoblazor.com/navigation and https://samples.geoblazor.com/drawing without letting the maps fully render will show the errors in the dev tools and an actual error message on screen briefly appears.
Expected Behavior
OnJavascriptError (and any other JS→.NET callbacks) should check IsDisposed before invoking .NET methods. An AbortError resulting from component disposal should be treated as expected, not exceptional.
Actual Behavior
Uncaught (in promise) Error: dymaptic.GeoBlazor.Core.Exceptions.JavascriptException: Aborted: Failed to load web map
at dymaptic.GeoBlazor.Core.Components.Views.MapView.OnJavascriptError(:5178/JavascriptError error)
at w.endInvokeDotNetFromJS (blazor.webassembly.js:1)
Also logged:
esri.WebMap #load() Failed to load web map e {name: 'AbortError', details: undefined, message: 'Aborted'}
Error building map view: TaskCanceledException_ctor_DefaultMessage
Suggested Fix
In OnJavascriptError and similar JS-invokable callbacks, add a disposal guard before invoking .NET:
Similarly, the JS interop layer could catch AbortError specifically when the view is being torn down and suppress the callback rather than propagating it back to .NET.
Workaround
Currently working around this with a combination of:
Navigation.RegisterLocationChangingHandler to set _renderMap = false and yield before navigation completes, giving Blazor time to unmount the component
- An
ErrorBoundary wrapper around MapView
- A JS
unhandledrejection filter targeting the specific error message
None of these are ideal as they operate at the wrong layer and are fragile against future library changes.
Description
When navigating away from a page containing a
MapViewwhile it is still initializing (specifically while theWebMap/ basemap is loading), an unhandled promise rejection escapes into the browser console and can surface as an application error:This happens because
esri.WebMap#load()is aborted mid-flight, which GeoBlazor correctly detects as anAbortError, but then calls back into .NET viaOnJavascriptErrorusinginvokeMethodAsync— at which point theMapViewcomponent has already been disposed. The resulting unhandled promise rejection bypassesErrorBoundaryentirely since it originates outside Blazor's render cycle.Environment
Steps to Reproduce
MapViewwith aWebMap(portal item) on a pageReproduced on Official Demo Site
This issue is reproducible on the GeoBlazor demo site itself, confirming it is not caused by
consumer code. Steps:
The
#blazor-error-uierror banner is suppressed on the demo site (likely via CSS),but the underlying unhandled exceptions are still visible in browser DevTools, confirming
the root cause is present regardless of the UI workaround.
The
TypeError: Cannot read properties of null (reading 'reject')originates in the ESRISDK's own layer view promise chain being torn down mid-flight, suggesting the fix needs to
account for both GeoBlazor's .NET disposal guards and graceful handling of the ESRI SDK's
async teardown.
Clicking between https://samples.geoblazor.com/navigation and https://samples.geoblazor.com/drawing without letting the maps fully render will show the errors in the dev tools and an actual error message on screen briefly appears.
Expected Behavior
OnJavascriptError(and any other JS→.NET callbacks) should checkIsDisposedbefore invoking .NET methods. AnAbortErrorresulting from component disposal should be treated as expected, not exceptional.Actual Behavior
Also logged:
Suggested Fix
In
OnJavascriptErrorand similar JS-invokable callbacks, add a disposal guard before invoking .NET:Similarly, the JS interop layer could catch
AbortErrorspecifically when the view is being torn down and suppress the callback rather than propagating it back to .NET.Workaround
Currently working around this with a combination of:
Navigation.RegisterLocationChangingHandlerto set_renderMap = falseand yield before navigation completes, giving Blazor time to unmount the componentErrorBoundarywrapper aroundMapViewunhandledrejectionfilter targeting the specific error messageNone of these are ideal as they operate at the wrong layer and are fragile against future library changes.