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

4.18.1 causes app to render in a <pre> tag when using unstable_getServerSession #5986

Closed
EvHaus opened this issue Dec 8, 2022 · 4 comments · Fixed by #5991
Closed

4.18.1 causes app to render in a <pre> tag when using unstable_getServerSession #5986

EvHaus opened this issue Dec 8, 2022 · 4 comments · Fixed by #5991
Labels
bug Something isn't working core Refers to `@auth/core` priority Priority fix or enhancement

Comments

@EvHaus
Copy link

EvHaus commented Dec 8, 2022

Environment

System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
Memory: 25.39 GB / 31.32 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 17.8.0 - ~/.nvm/versions/node/v17.8.0/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.5.5 - ~/.nvm/versions/node/v17.8.0/bin/npm
npmPackages:
next: 13.0.6 => 13.0.6
next-auth: 4.18.1 => 4.18.1
react: 18.2.0 => 18.2.0

Reproduction URL

https://stackblitz.com/edit/github-61ga3k-prdgby?file=pages%2Fserver.tsx

Describe the issue

After upgrading from 4.18.0 to 4.18.1 I'm seeing a very strange issue where my app no longer renders. Instead, Next renders the HTML of my app in a <pre> tag, so it looks like this:

image

What I've determined so far:

  • 4.18.0 doesn't have this bug
  • 4.18.1 and 4.18.3 have this bug
  • The issue only happens when using unstable_getServerSession
  • The issue only happens when you have logged in and have a session defined

How to reproduce

Check out the Stackblitz link I created. The issue is somewhat reproducible there. The "server" page there has a unstable_getServerSession used in getServerSideProps.

To reproduce the bug:

  • Run that Stackblitz example
  • Go to the "Server" page in the UI
  • Click on "Sign in" and try to sign in to one of the providers (doesn't mattern if you complete this or not)
  • Press the browser Back button to go back to the app
  • BUG: The UI no longer renders. Instead you get a <pre> tag with all the code of your app

Expected behavior

Bug doesn't happen. Next Auth should render the app as normal.

@EvHaus EvHaus added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Dec 8, 2022
@balazsorban44 balazsorban44 added bug Something isn't working and removed triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Dec 8, 2022
@balazsorban44
Copy link
Member

balazsorban44 commented Dec 8, 2022

Thanks, I identified the issue. As a workaround, you can set res.removeHeader("Content-Type") in your getServerSideProps after the unstable_getServerSession call.

The reason this happens is because unstable_getServerSession internally overrides the Content-Type to application/json, while the page using getServerSideProps should always return text/html.

A patch will be out today.

@balazsorban44 balazsorban44 added priority Priority fix or enhancement labels Dec 8, 2022
@balazsorban44 balazsorban44 added the core Refers to `@auth/core` label Dec 8, 2022
@balazsorban44
Copy link
Member

I have an experimental release you can test out! pnpm add [email protected]

@balazsorban44
Copy link
Member

A fix should be out for this in 4.18.4.

@EvHaus
Copy link
Author

EvHaus commented Dec 9, 2022

Confirmed 4.18.4 fixes the issue! Thanks for the fast fix. I found a new, different bug with 4.18.x though. Will open a new ticket shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core Refers to `@auth/core` priority Priority fix or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants