-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
(Batch)HttpLink: only swallow internal AbortError #11058
Conversation
🦋 Changeset detectedLatest commit: 4bf588a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
size-limit report 📦
|
src/link/batch-http/batchHttpLink.ts
Outdated
@@ -180,7 +181,7 @@ export class BatchHttpLink extends ApolloLink { | |||
.catch(err => { | |||
controller = undefined; | |||
// fetch was cancelled so its already been cleaned up in the unsubscribe | |||
if (err.name === 'AbortError') return; | |||
if (err.name === 'AbortError' && internalAbortSignal?.aborted) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I am not even sure if this line is necessary at all.
It was introduced back in 2017 with apollographql/apollo-link@c66b1da#diff-ab3906d63911de4980d8d24d3e314fd448eced2ead8ace4bb1d3ecb9b44bedad .
I cannot reproduce any situation where it would be necessary, but at can also not guarantee that this is always unneccesary, so I'm adding this additional check.
src/link/http/__tests__/HttpLink.ts
Outdated
it('aborting the internal signal will not cause an error', async () => { | ||
try { | ||
fetchMock.restore(); | ||
fetchMock.postOnce('data', async () => '{ "data": { "stub": { "id": "foo" } } }'); | ||
const abortControllers = trackGlobalAbortControllers(); | ||
|
||
const link = createHttpLink({ uri: '/data' }); | ||
execute(link, { query: sampleQuery } ).subscribe(failingObserver); | ||
abortControllers[0].abort(); | ||
} finally { | ||
fetchMock.restore(); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find a situation where this would normally be the case - the AbortController will only be aborted if the subsciption is unsubscribed, and any errors after that should not have any consequence anyways.
This is the closest test I could create to trigger a situation where the .abort()
call could have any consequence, and that's already testing implementation details.
since it would not have any consequence when triggered by internal `.abort()` calls.
@phryneas love it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Great change! Love the recognition that the conditional is not needed anymore.
This should fix #9583 as well. |
Fixes #10640
Checklist: