fix(interceptors): remove ejected handlers#11077
Open
rathodkunj2005 wants to merge 1 commit into
axios:v1.xaxios/axios:v1.xfrom
rathodkunj2005:fix/interceptor-manager-eject-compactsrathodkunj2005/axios:fix/interceptor-manager-eject-compactsCopy head branch name to clipboard
Open
fix(interceptors): remove ejected handlers#11077rathodkunj2005 wants to merge 1 commit intoaxios:v1.xaxios/axios:v1.xfrom rathodkunj2005:fix/interceptor-manager-eject-compactsrathodkunj2005/axios:fix/interceptor-manager-eject-compactsCopy head branch name to clipboard
rathodkunj2005 wants to merge 1 commit into
axios:v1.xaxios/axios:v1.xfrom
rathodkunj2005:fix/interceptor-manager-eject-compactsrathodkunj2005/axios:fix/interceptor-manager-eject-compactsCopy head branch name to clipboard
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Axios’s core InterceptorManager to fully remove ejected interceptors (no null slots), while keeping use() IDs stable so stale IDs can’t accidentally remove newer handlers after compaction. It adds unit tests to lock in the new compaction and ID-safety behavior.
Changes:
- Replace “null-slot” ejection with actual removal (
splice) and introduce stable numeric interceptor IDs (Symbol-backed per handler). - Simplify
forEachto no longer skipnullentries. - Add regression tests covering compaction, stale-ID safety, and order preservation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/core/InterceptorManager.js | Introduces stable interceptor IDs and removes handlers on eject to avoid null slots. |
| tests/unit/core/InterceptorManager.test.js | Adds targeted unit tests validating compaction, stale ID behavior, and ordering. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🏄
Summary
Verification
Summary by cubic
Removes ejected interceptors instead of leaving null slots and introduces stable numeric IDs to prevent stale removals. Adds focused tests to verify compaction, order, and stale ID safety.
Description
nextId.forEachsimple since there are no nulls to skip.usereturns a number;eject(id)still works.Docs
/docs/interceptor docs to clarify:forEachno longer needs to account for null entries.Testing
tests/unit/core/InterceptorManager.test.js:Semantic version impact
Written for commit 15424b9. Summary will update on new commits.