Skip to content

Does not gracefully handle AbortController with fetch #489

@swanson

Description

@swanson

👋

I have some fetch calls that are using AbortController (MDN) to cancel while they are in-flight. When this happens, a DomException error is raised, but generally clients want to catch it and ignore.

Since rack-mini-profiler patches fetch (see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/lib/html/includes.js#L936-L991), I can sometimes get raw Uncaught (in promise) DOMException: The user aborted a request. exceptions from the mini-profiler Javascript if I create and abort many fetches in quick succession.

I was able to make the errors go away by tacking on a catch(e => {}) to the Promise chain here, but wasn't sure if that was a good long-term fix.

Generally not a huge deal, but this will cause problems when deployed to non-development environments that have clientside JS error tracking services and was really confusing when developing to see unhandled errors (that our application was explicitly handling).

Any guidance on how to address this in the library or maybe even opt out of the fetch tracking behavior (I'd rather not have the metrics for JS request vs potential errors)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions