Skip to content

Conversation

@bhavesh112
Copy link

Describe your pull request here.

Fixes: #7044

It adds test cases and a fix to ensure onRequestError is triggered consistently when a request interceptor throws an error — both in synchronous and asynchronous modes.

Previously, Axios correctly handled synchronous interceptor errors but did not call onRequestError for asynchronous interceptors.

✅ Changes

  • Added two new test cases:
    • One for synchronous interceptor error handling.
    • One for asynchronous interceptor error handling.
  • Updated core logic to ensure consistent behavior for async interceptors.
  • Verified that all existing tests continue to pass.

🧪 Behavior Before

Mode Behavior
Synchronous onRequestError called ✅
Asynchronous onRequestError not called ❌

🧠 Behavior After

Mode Behavior
Synchronous onRequestError called ✅
Asynchronous onRequestError called ✅

Adds tests to verify onRequestError handling for both synchronous and asynchronous
request interceptors. Currently, the behavior is correct for synchronous interceptors
but failing for asynchronous ones.

Refs: axios#7044
Ensures that onRequestError is called when an asynchronous request interceptor throws.
Previously, the behavior matched for synchronous interceptors but failed for asynchronous
ones.

Closes: axios#7044
@github-actions github-actions bot added the pr::fix PR that fixes a bug label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr::fix PR that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to trigger axios request interceptor onRejected

1 participant