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

Include request and config when creating a CanceledError. - #4659

#4659
Merged
jasonsaayman merged 6 commits into
axios:masteraxios/axios:masterfrom
arthurfiorette:include-config-axios-abortCopy head branch name to clipboard
May 3, 2022
Merged

Include request and config when creating a CanceledError.#4659
jasonsaayman merged 6 commits into
axios:masteraxios/axios:masterfrom
arthurfiorette:include-config-axios-abortCopy head branch name to clipboard

Conversation

@arthurfiorette

Copy link
Copy Markdown
Contributor

Currently, only the error thrown by a canceled request does not maintain any data connection with its original request. This way, it's basically impossible to trace back which request was canceled based on just the error thrown.

This PR only enables all available parameters to the AxiosError instance: config and request.

function AxiosError(message, code, config, request, response) {

This way, any following CanceledError thrown will have the request and request config available.

@arthurfiorette arthurfiorette changed the title Include request config when creating a CanceledError. Include request and config when creating a CanceledError. May 1, 2022
@arthurfiorette

Copy link
Copy Markdown
Contributor Author

Specifically, this enables axios-cache-interceptor to remove the original loading cache state when a request is canceled. Because with the current error, it cannot find what request it was.

Comment thread lib/cancel/CanceledError.js
@jasonsaayman

Copy link
Copy Markdown
Member

Thanks for the PR looks great :)

@jasonsaayman
jasonsaayman merged commit ff1e5cd into axios:master May 3, 2022
@arthurfiorette
arthurfiorette deleted the include-config-axios-abort branch May 3, 2022 18:34
@arthurfiorette

Copy link
Copy Markdown
Contributor Author

Hey @jasonsaayman, sorry to bother you, but can you at least make a patch release with this fix soon?

@jasonsaayman

Copy link
Copy Markdown
Member

Cool I will try get the small changes cherry picked

@arthurfiorette

arthurfiorette commented Aug 18, 2022

Copy link
Copy Markdown
Contributor Author

Hey @jasonsaayman, sorry to bother you again...

Can this fix be released into a new v0 patch? It is leading to many bugs when integrating with onReject interceptors...

See arthurfiorette/axios-cache-interceptor/issues/317.

If you could just cherry pick this PR (and #4711 & #4922 [they are related]) to v0.27.3 would be awesome!!!

Thanks.

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.

3 participants

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