Skip to content

Next.js 15 canary with experimental PPR + dynamicIO issue calling headers() #4445

Description

@Jussinevavuori

Preliminary Checks

Reproduction

https://github.com/Jussinevavuori/clerk-next15-ppr-dynamicio-headers-issue

Publishable key

pk_test_ZnJlc2gtcmFtLTkxLmNsZXJrLmFjY291bnRzLmRldiQ

Description

Steps to reproduce:

  1. Clone reproduction repo.
  2. Install dependencies with bun install.
  3. Copy .env.example as .env and set up the required Clerk .env variables.
  4. Run with bun dev.

Expected behavior:

Should not cause any errors.

Actual behavior:

Causes below error.

 ⨯ unhandledRejection: Error: Clerk: auth() and currentUser() are only supported in App Router (/app directory).
If you're using /pages, try getAuth() instead.
Original error: Error: During prerendering, `headers()` rejects when the prerender is complete. Typically these errors are handled by React but if you move `headers()` to a different context by using `setTimeout`, `unstable_after`, or similar functions you may observe this error and you should handle it in that context.
    at buildRequestLike (turbopack://[project]/node_modules/@clerk/nextjs/src/app-router/server/utils.ts:35:10)
    at async getDynamicClerkState2 (turbopack://[project]/node_modules/@clerk/nextjs/src/app-router/server/ClerkProvider.tsx:17:18)
  33 |     }
  34 |
> 35 |     throw new Error(
     |          ^
  36 |       `Clerk: auth() and currentUser() are only supported in App Router (/app directory).\nIf you're using /pages, try getAuth() instead.\nOriginal error: ${e}`,
  37 |     );
  38 |   }

Environment

System:
    OS: macOS 15.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 201.53 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.2/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
    pnpm: 9.0.1 - ~/.nvm/versions/node/v18.20.2/bin/pnpm
    bun: 1.1.32 - ~/.bun/bin/bun
    Watchman: 2024.10.28.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 130.0.6723.92
    Safari: 18.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions