-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix cookie issues, add unit and e2e tests for cookies api #6648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: b576d02 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 is as far as I can take it, for now. I'd liked to have written more Playwright tests, but wasn't able to figure out fancier stuff, like testing enhanced forms. So the unresolved issue in #6609 I was only able to check by running the repro against this pr. But the perfect is the enemy of the good, and I'm confident that this is on the right track. Net: The main issue folks were having stemmed from Kit not setting |
|
It looks to me like you added the same tests to |
|
I just glanced quickly, but the Playwright tests look to me like they could cause flakiness. They run in parallel and are checking the same cookie values |
|
Thanks @cdcarson — re the parallel-tests-causing-flakiness thing @benmccann referred to, you can set a group of tests to run serially like so:
|
Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
|
I'm happy that this now fixes the issues we know about, knock on wood. Remaining todos, not necessarily blocking.
CookiesUnlike all other response headers, which you set with // example tktkThe {
httpOnly: true,
secure: true,
path: '/',
sameSite: 'lax'
}Also, implicitly, cookies are set to the session, so they will disappear after the user closes the browser. If you want a long-lasting cookie, set // example TKTK, including maxAgeImportant: If you do use your own values for Safari and dev mode: Safari does not send |
…/+page.svelte Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
|
I'm having issues setting cookies when they're being passed between server to server requests. Also when setting them in the load function (in +layout.server.ts). My code was working fine before switching to the new cookies API. Would you happen to know if this might fix those issues as well? Thanks... |
|
@DoisKoh Probably. There are some bugs in the current implementation that this PR fixes. @benmccann Do I have to take care of the failing mac tests in the CI? These pass on my mac, and I'm not sure what's going on. Perfectly willing to try to figure it out, but want to check if this is something that happens often, and if there's a trick. Thanks. |
|
@benmccann Ignore my last qusetion about mac ci tests. I figured it out. |
…moved empty unit tests
|
Thank you @cdcarson, this is awesome. I tried to make some changes locally and push them but for some reason it's not letting me, so I opened a new PR with those changes — we can either continue working in #6811 or you could merge that branch into this one. The only real question I had was around the |
@Rich-Harris Pretty sure it is necessary. See #6650. Basically a cookie set in a request to The only downside of having the default is if the site base path is |
There are some issues with cookie deletion unresolved in this issue: #6609
I believe the issue was that we were not setting the path on delete (and maybe on set.) Some tests are needed to confirm.
Marking this as draft until then.cookieserialize options from the SvelteKit cookies API(this should be a separate typescript issue)this is fixed by directly annotating theget,setanddeletewith JSDoc params rather than relying on the imported type ofcookiespathto other than '/') See this comment for suggested copy.Please 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. All changesets should bepatchuntil SvelteKit 1.0