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

Broken context w/ next 12.1.5-rc.2 and above #36198

Closed
1 task done
arcanis opened this issue Apr 15, 2022 · 7 comments · Fixed by #36206
Closed
1 task done

Broken context w/ next 12.1.5-rc.2 and above #36198

arcanis opened this issue Apr 15, 2022 · 7 comments · Fixed by #36206
Labels
bug Issue was opened via the bug report template.

Comments

@arcanis
Copy link
Contributor

arcanis commented Apr 15, 2022

Verify canary release

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

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #77~18.04.1-Ubuntu SMP Wed Mar 30 15:36:02 UTC 2022
Binaries:
  Node: 16.14.0
  npm: 8.3.1
  Yarn: 4.0.0-rc.2
  pnpm: N/A
Relevant packages:
  next: 12.1.6-canary.1
  react: 18.0.0
  react-dom: 18.0.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

An application I have is having a strange behavior after an upgrade from 12.1.0 to current. Bisecting the releases, the problem started in 12.1.5-canary.2. I presume it's from the React 18 upgrade, but I didn't try individual commits (is there an easy way to build them locally?).

I have some contexts defined inside layout components (using a pattern similar to the one described here), and since this upgrade those contexts are missing in the SSR build, crashing the direct page load (navigating to the page client-side works fine). It's almost as if pages were built without the _app wrapper.

Expected Behavior

Should work.

To Reproduce

To reproduce, clone https://github.com/arcanis/next-bug-context-ssr, run yarn && yarn next dev, and open localhost. It will crash. If you run yarn add next@12.1.5-canary.1 before restarting the server, it'll work.

@arcanis arcanis added the bug Issue was opened via the bug report template. label Apr 15, 2022
@arcanis
Copy link
Contributor Author

arcanis commented Apr 15, 2022

Bisecting commits, it seems the problem started with #35666 (cc @huozhi). I'm not too sure whether it's expected or not - I don't use server components, and my app file is _app.ts (not _app.client.ts), so I'd expect it to be applied on SSR rendering as well 🤔

@arcanis
Copy link
Contributor Author

arcanis commented Apr 15, 2022

I found a repro (also editing the OP to include these informations). It seems to be related to next-urql, although I don't know if the actual problem comes from them doing something bad, or Next having a regression.

To reproduce, clone https://github.com/arcanis/next-bug-context-ssr, run yarn && yarn next dev, and open localhost. It will crash. If you run yarn add next@12.1.5-canary.1 before restarting the server, it'll work.

@kodiakhq kodiakhq bot closed this as completed in #36206 Apr 16, 2022
kodiakhq bot pushed a commit that referenced this issue Apr 16, 2022
## Bug

The custom app is missing in the `ctx.AppTree` that causing the issue, it was accidently missed in custom _app.server pr #35666

Fixes #36198

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
@arcanis
Copy link
Contributor Author

arcanis commented Apr 16, 2022

Can confirm using a custom build now works, thanks for the quick fix!

@huozhi
Copy link
Member

huozhi commented Apr 16, 2022

Thanks for reporting and digging deep! 🙏

@ijjk
Copy link
Member

ijjk commented Apr 16, 2022

Hi, the above patch is now available in v12.1.6-canary.3 of Next.js, please update and give it a try!

@klarstrup
Copy link

My tests are now passing again as of next@12.1.6-canary.3!

@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 May 19, 2022
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants