Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add future flag to throw request.signal.reason for aborted requests #11104

Merged
merged 7 commits into from
Jan 26, 2024

Conversation

Copy link

changeset-bot bot commented Dec 8, 2023

🦋 Changeset detected

Latest commit: 219def2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@remix-run/router Minor
react-router Patch
react-router-dom Patch
react-router-dom-v5-compat Patch
react-router-native Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

) {
let method = isRouteRequest ? "queryRoute" : "query";
if (future.v7_throwAbortReason && request.signal.reason !== undefined) {
throw request.signal.reason;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only downside I see here is that we lose the request method/URL that we include in the custom error, but I think if folks need that then they should be passing a custom reason when they call controller.abort. Right now, in Remix we don't expose that for customization - but we could send our own DOMException with the method/URL in the message if we wanted to.

Comment on lines +738 to +741
// Note this works in Node 18+ - but it does not work if using the
// `abort-controller` polyfill which doesn't yet support a custom `reason`
// See: https://github.com/mysticatea/abort-controller/issues/33
controller.abort(new Error("Oh no!"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth calling out - this could be an issue in Remix apps that still use the polyfills if we wanted to use a custom reason

@brophdawg11 brophdawg11 merged commit c9f8a7b into dev Jan 26, 2024
3 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/abort-reason branch January 26, 2024 18:33
Copy link
Contributor

🤖 Hello there,

We just published version 6.22.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

github-actions bot commented Feb 1, 2024

🤖 Hello there,

We just published version 6.22.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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

Successfully merging this pull request may close these issues.

[Bug]: Error with message of "... call aborted" is thrown instead of standard DOMException
2 participants