Repository navigation
fix(cookies): clear host-only copies of overwritten chunks when domain is set - #309
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
Fixes #308.
When
cookieOptions.domainis set, the browsersetItemandapplyServerStorageemit a host-only clear only for chunks they remove. Chunks they overwrite keep the same names, so after a host-only to.parent.tldmigration the old host-only cookies stay until sign-out. Browsers list the older cookie first, andcookie.parsekeeps the first value for a name, so the client reads the old session and its refresh fails.What is the new behavior?
When
domainis set, the host-only clear also covers each chunk being written that already exists in the current cookies. The clears come before the sets, so cookie stores keyed by name only (Next.jsResponseCookies) still keep the domain-scoped set. Writes of new cookies and configurations withoutdomainare unchanged.Additional context
setItemchunk-cleanup test, which now also clears the host-onlystorage-key.setItemandapplyServerStorage, for new cookies (no host-only clear), and for a name-keyed store keeping the set.document.cookiepath and stores that emit oneSet-Cookieper entry clear the stale copy.