Skip to content
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

In layout.tsx that lives next to loader.tsx, headers are empty when navigated via Link #56068

Open
1 task done
danieltott opened this issue Sep 27, 2023 · 4 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@danieltott
Copy link
Contributor

danieltott commented Sep 27, 2023

Link to the code that reproduces this issue

https://github.com/danieltott/next-broken-linked-headers

To Reproduce

This does not happen when running pnpm dev or pnpm build && pnpm start locally on my mac (node v18.8.0), only on vercel

  1. Go to https://next-broken-linked-headers.vercel.app/
  2. Click the "set cookie" link
  3. Follow the links to see layouts that sit next to loading.tsx failing to read any headers upon client-side navigation

Current vs. Expected behavior

Current:
When navigating to a server component, headers is empty except for "next-url: /its-broken" (or whatever the url is).

Expected:
I can read headers/cookies in layout server components at any time.

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:34 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T8103
Binaries:
  Node: 18.8.0
  npm: 8.18.0
  Yarn: 1.22.19
  pnpm: 8.8.0
Relevant Packages:
  next: 13.5.4-canary.1
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A


warn  - Latest canary version not detected, detected: "13.5.4-canary.1", newest: "13.5.4-canary.0".
        Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.


Note - I don't see `13.5.4-canary.1` on the github releases page, but it is what `pnpm create next-app --example reproduction-template reproduction-app` installed.

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

App Router, Routing (next/router, next/navigation, next/link)

Additional context

I am 99% sure this is related to the changes in #55950

This problem does not happen in 13.5.3-canary.3, but starts in 13.5.3-canary.4 and later. You can see it working properly here: https://next-broken-linked-headers-git-version-1353-canary3-danieltott.vercel.app/ with 13.5.3-canary.3 installed.

headers is only empty in layout.tsx (not page.tsx) and only when layout.tsx is next to a loader.tsx.

@danieltott danieltott added the bug Issue was opened via the bug report template. label Sep 27, 2023
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Sep 27, 2023
@danieltott
Copy link
Contributor Author

I've had to pin to 13.5.3-canary.3 until this bug gets resolved.

@feliche93
Copy link

@danieltott thanks a ton for raising this. Have been debugging for several hours to find out the issue! This unblocked me 🙏

@danieltott
Copy link
Contributor Author

@feliche93 you're welcome - I spent most of yesterday tracking and narrowing it down 😅

zepez added a commit to zepez/nonovel that referenced this issue Sep 29, 2023
zepez added a commit to zepez/nonovel that referenced this issue Sep 29, 2023
@christo9090
Copy link

christo9090 commented Oct 2, 2023

I believe I am having the same issue but only in 13.5.3. Navigating using a next Link makes the root layout.tsx file act oddly. I am calling getServerSession for next auth. Works fine on initial load, but when navigating using a , the app shows I'm logged out. I am guessing this is related because the cookie would be missing in the layout file.

13.5.2 this issue is not present. This only happens in production when deployed and not in dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

3 participants