Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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#11077
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

@rathodkunj2005

@rathodkunj2005 rathodkunj2005 commented Jul 13, 2026

Copy link
Copy Markdown

🏄

Summary

  • remove ejected interceptor records instead of leaving null slots behind
  • keep stable interceptor ids so stale ids cannot remove later handlers after compaction
  • add focused InterceptorManager regression tests for compaction, stale ids, and order preservation

Verification

  • npm run test:vitest:unit -- tests/unit/core/InterceptorManager.test.js
  • npx eslint lib/core/InterceptorManager.js tests/unit/core/InterceptorManager.test.js

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

  • Summary of changes
    • Remove ejected handlers with splice; no more null slots.
    • Add stable numeric IDs via a private symbol and nextId.
    • Keep forEach simple since there are no nulls to skip.
  • Reasoning
    • Avoid sparse arrays and reduce memory growth.
    • Prevent stale IDs from removing later handlers.
    • Preserve insertion order after ejections.
  • Additional context
    • Public API is unchanged: use returns a number; eject(id) still works.
    • Behavior is backward compatible and internal-only.

Docs

  • Update /docs/ interceptor docs to clarify:
    • IDs are stable and not tied to array indices.
    • Ejected handlers are removed, not set to null.
    • forEach no longer needs to account for null entries.

Testing

  • Added unit tests in tests/unit/core/InterceptorManager.test.js:
    • Ensures no null slots remain after many add/eject cycles.
    • Verifies stale IDs cannot remove newer handlers.
    • Confirms insertion order is preserved after middle ejections.

Semantic version impact

  • Patch: internal behavior change with no public API breakage.

Written for commit 15424b9. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 forEach to no longer skip null entries.
  • 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.

Comment thread lib/core/InterceptorManager.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.