Skip to content

@next/playwright instant() clears testing cookies for other origins #96961

Description

@teamleaderleo

Link to the code that reproduces this issue

https://github.com/teamleaderleo/playground/tree/repro/next-playwright-origin-cookie/next-playwright-origin-cookie-repro

To Reproduce

  1. Clone the reproduction and switch to the repro/next-playwright-origin-cookie branch.
  2. Open next-playwright-origin-cookie-repro.
  3. Run:
npm install
npx playwright install chromium
npm test

The reproduction creates a Playwright BrowserContext, adds a next-instant-navigation-testing cookie for app-b.example, and then calls instant() for app A using baseURL: 'https://app-a.example/'.

The assertion inside instant() fails because app B's cookie has already been removed:

AssertionError: app B cookie was removed by instant() for app A

actual:   undefined
expected: '[1,"app-b",null]'

Current vs. Expected behavior

Calling instant() for app A can remove a next-instant-navigation-testing cookie that applies to app B in the same Playwright BrowserContext.

I expect instant() to clean up testing cookies that apply to the application URL it is controlling, without removing cookies for other applications.

Provide environment information

Node.js: v22.23.1
@next/playwright: 16.3.1-canary.8
Playwright: 1.61.1

`next info` is not applicable to this reproduction due to isolating the `@next/playwright` package behavior.

Which area(s) are affected? (Select all that apply)

Cookies, Testing

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    CookiesRelated to the async cookies() function.TestingRelated to testing with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions