Skip to content

Conversation

@ascorbic
Copy link
Contributor

Changes

Currently, when a cookie is first parsed from the header the value is cached. This means that if subsequent requests pass a different decode function it will be ignored. This PR changes the behaviour to cache the raw cookie values, and then decode them when getting them. This means the passed decode function will always be used.

Fixes #13078

Testing

Docs

@changeset-bot
Copy link

changeset-bot bot commented Mar 21, 2025

🦋 Changeset detected

Latest commit: c3929be

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 21, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 21, 2025

CodSpeed Performance Report

Merging #13485 will not alter performance

Comparing cookie-encode (c3929be) with main (70c9595)

Summary

✅ 6 untouched benchmarks

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Can we add a test to avoid possible future regressions?

@ascorbic ascorbic requested a review from ematipico March 25, 2025 15:18
Comment on lines -141 to +146
return !!values[key];
const values = this.#ensureParsed();
return values[key] !== undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously it would return false for has() when the cookie had a falsy value, even if it existed

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Thank you!

@ascorbic ascorbic merged commit 018fbe9 into main Mar 26, 2025
16 checks passed
@ascorbic ascorbic deleted the cookie-encode branch March 26, 2025 09:03
@astrobot-houston astrobot-houston mentioned this pull request Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cookies from header not parsed by AstroCookies

2 participants