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

[NEXT-670] Faulty app/ Static to Dynamic Error When POST fetches are used from layout.tsx #46436

Closed
1 task done
kulgg opened this issue Feb 26, 2023 · 13 comments · Fixed by #46597
Closed
1 task done
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@kulgg
Copy link

kulgg commented Feb 26, 2023

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 21.6.0: Sat Jun 18 17:07:28 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T8110
Binaries:
  Node: 16.16.0
  npm: 8.11.0
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 13.2.2-canary.1
  eslint-config-next: 13.2.1
  react: 18.2.0
  react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), Data fetching (gS(S)P, getInitialProps)

Link to the code that reproduces this issue

https://github.com/kulgg/app-static-to-dynamic-reproduction

To Reproduce

Start the development server and navigate to /one.
The app/ Static to Dynamic Error will be shown.

Describe the Bug

POST request fetches from a layout component inside a dynamic segment route that uses generateStaticParams will lead to a faulty app/ Static to Dynamic Error.
GET requests work without problems.

On build the should-be SSG routes turn into server-side rendered routes.

Expected Behavior

As with GET requests, the statically generated dynamic segment routes should be generated for POST requests without problems

Which browser are you using? (if relevant)

Brave Version 1.48.171 Chromium: 110.0.5481.177

How are you deploying your application? (if relevant)

No response

NEXT-670

@kulgg kulgg added the bug Issue was opened via the bug report template. label Feb 26, 2023
@itsuki0927
Copy link

+1

1 similar comment
@semy
Copy link

semy commented Feb 26, 2023

+1

@rakoort
Copy link

rakoort commented Feb 26, 2023

Similar issue happening here, both on layout and individual page files. GraphQL fetch requests using POST are returning undefined.

I have one header/footer fetch in the root layout and a page fetch under a page slug folder. Interestingly it fetches either one or the other, but never both at the same time. All my fetches have a revalidate setting, but I can load one page fine if I swap out the header/footer fetch revalidate setting with force cache. At this point a route change will trigger the same static to dynamic error as mentioned in the OP.

@hiddenest
Copy link
Contributor

How about adding next: { revalidate: 10 } to fetch requests?
I had a similar issue with this, and solved by adding revalidate option to each requests.
(but don't know why exactly it occurs error)

@semy
Copy link

semy commented Feb 27, 2023

For me next: { revalidate: 10 } works for POST GraphQL requests locally, but as soon as I roll it out in Production it doesn't work anymore and I get weird results. I have to test it with the last canary.

@kulgg
Copy link
Author

kulgg commented Feb 27, 2023

Interesting next: { revalidate: 10 } seems to fix it for me both for the dev and prod server. However it shouldnt be necessary.

@hiddenest
Copy link
Contributor

Agree. I'm guessing that the new cache policy in 13.2 is that requests with revalidate: 0 or no revalidate setting are automatically assumed to be dynamic content. 🤔

@sairion
Copy link

sairion commented Feb 27, 2023

c533613#diff-4c54e369ddb9a2db1eed95fe1d678f94c8e82c540204475d42c78e49bf4f223aR64-R66 not sure, but this diff seems to be triggering it?

update: I tried run without it, and without the part, repro is working fine

Screen Shot 2023-02-27 at 8 10 06 PM

@timneutkens timneutkens added the linear: next Confirmed issue that is tracked by the Next.js team. label Feb 27, 2023
@timneutkens timneutkens changed the title Faulty app/ Static to Dynamic Error When POST fetches are used from layout.tsx [NEXT-670] Faulty app/ Static to Dynamic Error When POST fetches are used from layout.tsx Feb 27, 2023
@r-martins
Copy link

r-martins commented Mar 1, 2023

Similar issue here, already reported #45134.
If I downgrade from 13.2 to 13.1.6-canary.0 it works.
The bug was introduced in 13.2.2-canary.0.

@semy
Copy link

semy commented Mar 1, 2023

But when you downgrade you have other problems with fetch. So this is no Solution.

ijjk added a commit that referenced this issue Mar 1, 2023
This corrects the static to dynamic error incorrectly showing in
development since we don't have enough information to accurately know if
this error should be thrown or not unless a build has been done.

Fixes: #46436
x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1677637140906959)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
@ijjk
Copy link
Member

ijjk commented Mar 1, 2023

Hi, this has been updated in v13.2.3-canary.1 of Next.js, please update and give it a try!

@r-martins
Copy link

Thanks a lot @ijjk .
Couldn't be faster! thanks 💯

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants