Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Chanran
Copy link

@Chanran Chanran commented Sep 16, 2025

We encountered a major source of jank because axios uses the synchronous API document.cookie(see whatwg/html#11658). Currently, the asynchronous API CookieStore serves as an alternative, so I create this to contribute to axios.

@github-actions github-actions bot added the pr::feature PR that adds a feature label Sep 16, 2025
@Chanran Chanran force-pushed the lcr/feat-use-cookiestore-insteadof-document-cookie branch from d3cd889 to 9f794da Compare September 16, 2025 17:07
@Chanran
Copy link
Author

Chanran commented Sep 17, 2025

@jasonsaayman Hi, could you feel free to help review this pr? I have ran tests and lints and passed.

@Chanran Chanran force-pushed the lcr/feat-use-cookiestore-insteadof-document-cookie branch from a982f5b to 73d4f8f Compare September 27, 2025 17:45
@jasonsaayman jasonsaayman requested a review from Copilot October 10, 2025 09:26
Copy link
Contributor

Copilot AI left a 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 PR modernizes axios's cookie handling by replacing the synchronous document.cookie API with the asynchronous cookieStore API to eliminate jank issues. The implementation includes fallback support for browsers without cookieStore support.

  • Converts cookie operations (read, write, remove) from synchronous to asynchronous
  • Updates resolveConfig function to handle async cookie reading for XSRF tokens
  • Modifies XHR and fetch adapters to properly handle the async configuration resolution

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/helpers/cookies.js Implements cookieStore API with document.cookie fallback
lib/helpers/resolveConfig.js Updates XSRF token reading to be async
lib/adapters/xhr.js Wraps resolveConfig call in Promise chain
lib/adapters/fetch.js Adds await to resolveConfig call
test/specs/helpers/cookies.spec.js Updates tests to handle async cookie operations
test/specs/requests.spec.js Modifies timeout tests and adds cookieStore mocking

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jasonsaayman
Copy link
Member

please can you rebase based on the changes in #7129

@Chanran Chanran force-pushed the lcr/feat-use-cookiestore-insteadof-document-cookie branch from 5079539 to 3997555 Compare October 11, 2025 14:52
@Chanran
Copy link
Author

Chanran commented Oct 11, 2025

@jasonsaayman Already rebased. Please review again.
@Amitverma0509 And feel free to review my pr cause I rebase your pr.

@Chanran
Copy link
Author

Chanran commented Oct 15, 2025

@jasonsaayman Please feel free to review and merge. We need to use new axios npm package to avoid jank in PC client. And I want to know the date next version 1.12.3 release. Thanks for maintaining this greate project!

@DigitalBrainJS
Copy link
Collaborator

Unfortunately, we have a problem here, as this will introduce a hidden regression for #2609. This is why we avoided implementing features that require an asynchronous API before requesting with the underlying transport within v0.x and v1.x as we shouldn't introduce a breaking change within the major version. The regression isn't that severe, but I'm not sure if we should break the rules to land this in 1.x

@Chanran
Copy link
Author

Chanran commented Oct 20, 2025

@DigitalBrainJS But I found "lib/adapters/fetch.js" use promise to resolveBodyLength before requesting with the underlying transport too.

@DigitalBrainJS
Copy link
Collaborator

Yes, because at the time of the first 1.x release, the tests only covered the XHR adapter.
The Fetch adapter was released later, it was a new feature and therefore it couldn’t introduce a breaking change, since it simply didn’t exist before.
In the next major version we’re going to change this behavior of the XHR adapter, but in the current version our hands are tied.
We can extend functionality, but we must guarantee that the behavior of existing functionality will not change during the 1.x version. At least that’s how it should be.

There are three possible ways out:

  • We turn a blind eye to it and introduce a slight discrepancy, although there’s a chance that someone will notice a regression (probably requires debate)
  • We find a way to introduce the new behavior through a temporary option in the transitional config (which is what it was originally created for).
  • We keep this PR until the next major release, but it probably won’t happen soon, as there are still a lot of features planned for the 1.x version.

@github-actions github-actions bot added the pr::types PR that changes project types definiton (.d.ts) label Oct 21, 2025
@Chanran Chanran force-pushed the lcr/feat-use-cookiestore-insteadof-document-cookie branch from 4ca73c6 to 112801a Compare October 21, 2025 01:23
@github-actions github-actions bot added the pr::docs PR that changes project documentation label Oct 21, 2025
@Chanran
Copy link
Author

Chanran commented Oct 21, 2025

@DigitalBrainJS Hi, I have done option 2. Using a optional config to get resolveConfig in asynchronous way. Please feel free to review again. Thanks!

@Chanran Chanran force-pushed the lcr/feat-use-cookiestore-insteadof-document-cookie branch from 112801a to 373c315 Compare October 21, 2025 01:29
@Chanran
Copy link
Author

Chanran commented Nov 4, 2025

Tests all passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr::docs PR that changes project documentation pr::feature PR that adds a feature pr::types PR that changes project types definiton (.d.ts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants