Skip to content

Clerk core v2 - Clerk fails to load under cypress iframe - "Browser unauthenticated" #3369

Closed

Description

@AlonMiz

Preliminary Checks

Reproduction

https://github.com/clerk/example-cypress-nextjs

Publishable key

pk_test_cHJvcGVyLXNwYXJyb3ctNDkuY2xlcmsuYWNjb3VudHMuZGV2JA

Description

Im struggling with upgrading to the latest clerk. i already migrated the app to the new core, but all of my e2e tests are broken now.

Steps to reproduce:

  1. Upgrading to latest Clerk
  2. run e2e tests

Expected behavior:

tests should work as before

Actual behavior:

tests are failing with cookie issues

{
    "errors": [
        {
            "message": "Browser unauthenticated",
            "long_message": "Unable to authenticate this browser for your development instance. Check your Clerk cookies and try again. If the issue persists reach out to support@clerk.com.",
            "code": "dev_browser_unauthenticated"
        }
    ],
    "clerk_trace_id": "7d1c50d0956fd9d3fcf0e724ee113c37"
}

    "@clerk/clerk-sdk-node": "5.0.0",
    "@clerk/nextjs": "5.0.1",
    "@clerk/themes": "2.0.0",
    "next": "14.2.2",

exception

Uncaught (in promise) Error: ClerkJS: Something went wrong initializing Clerk.
    at o (VM2800 clerk.browser.js:2:73614)
    at $e.<anonymous> (VM2800 clerk.browser.js:2:223897)
    at async $e.load (VM2800 clerk.browser.js:2:202798)
    at async _IsomorphicClerk.loadClerkJS (VM2822 node_modules_@clerk_clerk-react_dist_51047c._.js:1728:17)

sign in method

Cypress.Commands.add(`signIn`, () => {
  cy.log(`Signing in.`);
  cy.setCookie(languageUtils.languageCookieKey, 'he');
  cy.visit('/');

  cy.window().should((win) => {
    expect(win).to.not.have.property(`Clerk`, undefined);
    expect(win.Clerk?.loaded).to.eq(true);
  });
  cy.window().then((win) => {
    cy.clearCookies({ domain: win.location.host });
    cy.log(`Clear cookies.`);
  });
  cy.window().then(async (win) => {
    cy.log(`Creating user.`);
    await win.Clerk.signOut();
    const res = await win.Clerk.client?.signIn.create({
      identifier: 'clerk_test@example.com',
      password: 'asdqwe123',
    });
    cy.log(`Signing in.`);
    await win.Clerk?.setActive?.({
      session: res?.createdSessionId,
    });
    cy.log(`Finished Signing in.`);
  });
});

Environment

System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 59.81 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.volta/tools/image/node/20.11.0/bin/node
    Yarn: 1.22.18 - ~/.volta/tools/image/yarn/1.22.18/bin/yarn
    npm: 10.2.4 - ~/.volta/tools/image/node/20.11.0/bin/npm
    pnpm: 8.5.0 - ~/Library/pnpm/pnpm
    bun: 1.0.1 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 106.1.44.105
    Chrome: 124.0.6367.158
    Safari: 17.4.1
  npmPackages:
    @clerk/clerk-sdk-node: 5.0.5 => 5.0.5
    @clerk/nextjs: 5.0.8 => 5.0.8
    @clerk/themes: 2.1.3 => 2.1.3
    cypress: 13.9.0 => 13.9.0
    next: 14.2.3 => 14.2.3
    react: 18.3.1 => 18.3.1
    react-dom: 18.3.1 => 18.3.1

Activity

  1. added
    needs-triageA ticket that needs to be triaged by a team member
    on May 11, 2024
  2. added and removed
    needs-triageA ticket that needs to be triaged by a team member
    on May 13, 2024
  3. LekoArts commented on May 13, 2024

    @LekoArts
    Contributor

    Hi!

    I think this could be fixed by #3245 but it wasn't released yet to autoload for everyone.

    Can you change your <ClerkProvider> inside your Next.js application to the following?

    <ClerkProvider clerkJSVersion="5.2.3-snapshot.v47a3ff9">

    And then try again? This would be a temporary test of the new version to see if it works.

  4. LekoArts commented on May 13, 2024

    @LekoArts
    Contributor

    #3245 was released now. Please retry again with latest versions.

  5. AlonMiz commented on May 13, 2024

    @AlonMiz
    Author

    Thanks @LekoArts it does work now 🥳
    ill update if anything goes wrong 😉

  6. clerk-cookie commented on May 14, 2025

    @clerk-cookie
    Collaborator

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  7. locked as resolved and limited conversation to collaborators on May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions