fix: make cookie options optional - #17201
Merged
Merged
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/8f666211f89b9d01d32ac5b3473af1dbecd88594Open in |
🦋 Changeset detectedLatest commit: 8f66621 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This was referenced Sep 24, 2026
… options-2's `hooks.server.js`, so `count.remote.js` can no longer isolate its in-memory count per browser session, reintroducing parallel-test state clobbering.
This commit fixes the issue reported at packages/kit/test/apps/options-2/src/hooks.server.js:3
## Bug
The commit **"path: '/' is the default"** (whose stated intent was to make cookie `options` optional, since `path` defaults to `'/'`) removed the *entire* session-cookie-setting block from `packages/kit/test/apps/options-2/src/hooks.server.js`, rather than just the now-unnecessary `{ path: '/' }` argument.
Git diff confirms:
```diff
export async function handle({ event, resolve }) {
- // isolates the in-memory count in count.remote.js per browser session
- if (!event.cookies.get('session')) {
- event.cookies.set('session', crypto.randomUUID(), { path: '/' });
- }
return resolve(event, {
```
## Why it matters
`src/routes/remote/count.remote.js` keys its in-memory `counts` Map by the `session` cookie:
```js
const session_id = () => getRequestEvent().cookies.get('session') ?? 'default';
```
with the comment: *"count is keyed by the `session` cookie from hooks.server.js so the parallel tests that read and set it can't see each other's mutations."*
**Trigger:** With the block removed, no request ever sets a `session` cookie, so `session_id()` always returns `'default'`. All parallel Playwright workers/browsers then share the single `'default'` entry in `counts`, so concurrent `get_count` / `set_count` / `set_count_form` calls clobber each other — exactly the cross-test flakiness the code was designed to prevent.
The sibling `async` app's `hooks.server.js` in the same PR correctly kept its equivalent session-isolation block and only dropped `path`, confirming this deletion was accidental.
## Fix
Restore the block, dropping only the `{ path: '/' }` argument (matching the PR's intent):
```js
// isolates the in-memory count in count.remote.js per browser session
if (!event.cookies.get('session')) {
event.cookies.set('session', crypto.randomUUID());
}
```
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: teemingc <chewteeming01@gmail.com>
Rich-Harris
approved these changes
Sep 24, 2026
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.
Since cookie paths now default to
'/', we can make the third argument optional. This PR changes the types and updates docs/testsPlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits