-
Notifications
You must be signed in to change notification settings - Fork 5
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
Abort signal is not respected #25
Comments
This could be why the first request takes so long with ipfs/service-worker-gateway#122 Will investigate further tomorrow |
verified that when updated to 1.3.0, fetchIPNS and then abort result in "400" status code: https://codesandbox.io/p/sandbox/heali-verified-fetch-example-m5zmfd?file=%2Findex.html sometimes the buttons don't seem to trigger anything, but I believe this is resolved 👍 |
https://developer.mozilla.org/en-US/docs/Web/API/AbortController
|
we can't actually throw a legit some context in: nodejs/node#40692 |
Thanks @SgtPooki! The only thing that's a bit burdensome about the custom AbortError is that it doesn't have the So checking for this error either requires importing the error type: import {AbortError} from '@libp2p/interface'
...
} catch (err) {
if(err instanceof AbortError) {
console.log('all good 🎉 no need to set error since the user aborted.')
}
... I tried checking the custom SuggestionGiven this, I think it would be useful to follow the same convention as built-in error objects and set the } catch (err) {
if(err instanceof Error && err.name === 'AbortError') {
console.log('all good 🎉 no need to set error since the user aborted.')
}
... WDYT, @SgtPooki ? |
@2color that sounds good.. I think we should add a .name property to errors in libp2p. However, I think that libp2p checks AbortError has a |
The problem with |
Normally you'd just do something like this: } catch (err: any) {
if (err.code === 'ABORT_ERR') {
console.log('all good 🎉 no need to set error since the user aborted.')
} The |
As discussed in ipfs/helia-verified-fetch#25 (comment), this PR adds the name property to the AbortError type. This has a couple of benefits: - Sticks the common convention for Error types (all built in Error types have the name property set to the class name) - Allows checking the error type at runtime in a TS codebase without importing the type Co-authored-by: Daniel N <[email protected]>
AFAIK, all we should need to do here now is update to latest helia + libp2p and we should be good to go, right? |
|
When passing an
new AbortController().signal
to a verifiedFetch request, aborting does not seem to work.You can see this in action in the reproduction, where if you click to fetch IPNS and right after click Abort Fetch, the
controller.abort()
call does not cause the promise from theverifiedFetch
call to throw an error as you'd expect inFetch
To make this easier to test, I've added a reproduction:
Reproduction
The text was updated successfully, but these errors were encountered: