-
-
Notifications
You must be signed in to change notification settings - Fork 66
Fix: canceled requests no longer propagate errors to deduplicated requests #1172
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
Conversation
- When a request is aborted (ERR_CANCELED), resolve the deferred instead of rejecting it - This allows other waiting requests to proceed with their own network call - Added comprehensive tests to verify the fix - Updated existing test to reflect the new expected behavior Co-authored-by: arthurfiorette <[email protected]>
- Add proper type for Promise in abort request test - Fix linter warnings and formatting Co-authored-by: arthurfiorette <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1172 +/- ##
=======================================
Coverage 98.77% 98.77%
=======================================
Files 20 20
Lines 3092 3099 +7
Branches 272 275 +3
=======================================
+ Hits 3054 3061 +7
Misses 36 36
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This pull request fixes a bug where canceled requests with deduplication were incorrectly propagating ERR_CANCELED errors to all waiting deduplicated requests, causing subsequent requests for the same resource to fail even though they weren't canceled.
Changes:
- Modified response interceptor to resolve deferred promises instead of rejecting them when a request is canceled
- Updated test expectations to reflect that waiting requests should succeed after a cancellation
- Added comprehensive test coverage for various abort scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/interceptors/response.ts | Modified error handling to resolve deferred for ERR_CANCELED instead of rejecting, allowing waiting requests to make their own network calls |
| test/interceptors/response.test.ts | Updated existing test expectations to verify waiting requests succeed after first request is canceled |
| test/interceptors/abort-request.test.ts | Added new comprehensive test suite covering sequential abort/retry, immediate abort/retry, and multiple concurrent requests scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // p2 should succeed by making its own network call | ||
| // This is the fix for the issue where canceled requests were incorrectly | ||
| // propagating errors to other waiting requests | ||
| const result = await promise; | ||
| assert.equal(result.cached, false); // Made a new network call | ||
| assert.ok(result.data); | ||
|
|
||
| const storage = await axios.storage.get(id); | ||
|
|
||
| // Cache should be empty since the request was cancelled | ||
| assert.equal(storage.state, 'empty'); | ||
| // Cache should now be populated from the successful second request | ||
| assert.equal(storage.state, 'cached'); |
Copilot
AI
Jan 21, 2026
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.
The test name "Cancelled deferred propagates error to all waiting requests" is now misleading since the test validates that waiting requests should succeed (not receive the error). Consider updating the test name to reflect the new behavior, such as "Cancelled request does not propagate error to waiting deduplicated requests" or "Waiting requests succeed after first request is cancelled".
When a request with deduplication is canceled, it was rejecting the shared deferred, causing all waiting requests to fail with ERR_CANCELED. Subsequent requests for the same resource would fail even though they weren't canceled.
Example of the issue:
Changes
Response interceptor (
src/interceptors/response.ts)Test coverage (
test/interceptors/abort-request.test.ts)Updated expectations (
test/interceptors/response.test.ts)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
REDACTED-url.lan/usr/local/bin/node /usr/local/bin/node --import ./test/setup.js --enable-source-maps /home/REDACTED/work/axios-cache-interceptor/axios-cache-interceptor/test/interceptors/stale-if-error.test.ts(dns block)/usr/local/bin/node /usr/local/bin/node --import ./test/setup.js --enable-source-maps /home/REDACTED/work/axios-cache-interceptor/axios-cache-interceptor/test/interceptors/stale-if-error.test.ts test/interceptors/hydrate.test.ts test/interceptors/last-modified.test.ts test/interceptors/request.test.ts test/interceptors/response.test.ts test/interceptors/stale-if-error.test.ts test/interceptors/util.test.ts test/interceptors/vary.test.ts(dns block)/usr/local/bin/node /usr/local/bin/node --import ./test/setup.js --enable-source-maps /home/REDACTED/work/axios-cache-interceptor/axios-cache-interceptor/test/interceptors/stale-if-error.test.ts --enable-sourceOUTPUT(dns block)REDACTED.url.lan/usr/local/bin/node /usr/local/bin/node --import ./test/setup.js --enable-source-maps /home/REDACTED/work/axios-cache-interceptor/axios-cache-interceptor/test/interceptors/response.test.ts(dns block)/usr/local/bin/node /usr/local/bin/node --import ./test/setup.js --enable-source-maps /home/REDACTED/work/axios-cache-interceptor/axios-cache-interceptor/test/interceptors/stale-if-error.test.ts(dns block)/usr/local/bin/node /usr/local/bin/node --import ./test/setup.js --enable-source-maps /home/REDACTED/work/axios-cache-interceptor/axios-cache-interceptor/test/interceptors/response.test.ts test/interceptors/hydrate.test.ts test/interceptors/last-modified.test.ts test/interceptors/request.test.ts test/interceptors/response.test.ts test/interceptors/stale-if-error.test.ts test/interceptors/util.test.ts test/interceptors/vary.test.ts(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.