NextAuth auth flow causes Next.js 13 dev server to crash without throwing any errors
I'm building a note-taking app with ct3a (partly inspired by Jack Herrington's awesome T3 video) but I'm having a really weird issue with NextAuth where the auth flow succeeds, OAuth2 callback route is hit, but then for some reason the Next.js dev server crashes without throwing any errors whatsoever.
I'm positive the auth flow is working properly because running NextAuth in debug mode shows a successful OAuth2 callback response with data - but it's still not throwing errors. Here's a slightly censored version of the console output from NextAuth:
Currently my NextAuth config has Google and Discord as OAuth providers, but they both end up crashing the Next.js dev server inexplicably.
Here is the repo - relevant code can be found in the editor branch. No detailed README yet but it's just a standard ct3a Next.js project: Prisma, Tailwind, NextAuth, TRPC
https://github.com/ChromeUniverse/luccanotes/tree/editor
GitHub
GitHub - ChromeUniverse/luccanotes at editor
A full-stack note-taking app for Markdown lovers â€ïž - GitHub - ChromeUniverse/luccanotes at editor
101 Replies
share github repo
yep just pushing some changes to a new branch
ima spin up postgres and run it see what happens
okie dokie, much appreciated - I've added some more info in the main post
Oh, interestingly enough, Vercel shows some errors on build
Ah never mind, it's just complaining that I forgot to set the env vars on Vercel but I don't think that's useful
I've added a dummy login button that invokes NextAuth's
signIn()
methodfor me its saying its missing type defs for @codemirror\state
Huh
fixed it idk what happened lol
Wait that doesn't make sense
npm
@codemirror/state
Editor state data structures for the CodeMirror code editor. Latest version: 6.2.0, last published: 2 months ago. Start using @codemirror/state in your project by running
npm i @codemirror/state
. There are 263 other projects in the npm registry using @codemirror/state.look, @codemirror/state has built-in TS defs
i did pnpm i @codemirror/state and it worked, idk why it didnt install when i did pnpm i
well shoot
so, i can login just fine but i did 1 change, i removed google cuz never set that shit up for oauth but ill try with it
I just checked and
@codemirror/state
really wasn't in the package.json lol
My badoh lol makes more sense now ð€£
Oh shoot so you got it the login to work on your end?
yh
So I'm assuming you just removed the
GoogleProvider()
setup in /src/server/auth.ts
?yh
Tried doing the same but the Discord login option still isn't working either
What really boggles my mind is that the Next.js dev server just crashes without throwing any errors
everything is working for me
bruh
what am I missing here lol
added google too works fine
hates me
what the actual heck
how did you setup your callbacks
Yeah that's exactly how I set up mine too
removing google didnt work for you?
Don't think I'm missing anything here
Nope
hmm
wdym by it crashes
it just goes down?
Yeah the dev server just exits and doesn't throw any errors to the console
what about the browser
This is all I'm getting
like the console before it goes blank
in browser
Oh
Lemme check
Nope, nothing - this is all I get when trying to login with Discord:
node version?
Preserve log is turned on, that message with the
https://discord.com/jobs
is the last thing that appears before getting redirected to the callback URL
v19.2.0ohh might be it
get LTS
next auth has been a pain with versions from time to time
Oh
Should I downgrade to the latest LTS then?
yh
okay lemme try that then
Alright I installed 18.14.2 with
nvm
let's see how this goes
Shit, no luck ð
Same thing stillwhat about
the good old restart pc
lmao
i'll take what I can get at this point
I think I'll try reinstalling my dependencies first
nope nothing
I'll try restarting my computer, brb
i can build just fine same versions of node npm everything, login works idk whats happening lol
Restarted my laptop, still no dice. This is such a weird error. I don't have any other machines on hand, so I'm just gonna try doing a preview deployment to Vercel, changing my callback URLs and hope for the best
https://luccanotes-git-editor-chromeuniverse.vercel.app/
Right so I managed to not get any errors or weird behaviors on this preview deployment on it means it's working...? I haven't added any visible way to make sure you're logged in... ð ð€Šââïž
Okay so I finally got something
I built the next app locally and ran it the built app with
npm run start
When I try doing the login flow I get a segfault of some sort
The Next dev server exists with status 139Okay so I did a full freakin reinstall of Node.js, npm and nvm as per this very thorough Stack Overflow answer:
https://stackoverflow.com/questions/32426601/how-can-i-completely-uninstall-nodejs-npm-and-node-in-ubuntu/60701804#60701804
Stack Overflow
How can I completely uninstall nodejs, npm and node in Ubuntu
The Question is similar to How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X) but for Ubuntu, and just for uninstalling.
Installation was done by: sudo apt-get install n...
BUT IT'S STILL NOT WORKING AFKJASADKJFHASKDF
Went back to basics and created a new t3 starter app just to find out whether it's a problem with my machine or with my current project
And it looks like NextAuth and tRPC are working fine on the basic t3 app so that should isolate the problem to my current project, right...? <a:pooh_think:1051378453724794941>
I wonder if it's a problem with Prisma
The start app is using SQLite but I'm using Postgres with Supabase
You did prisma db push right
@barry Spun up a new Postgres DB locally and it's perfectly working fine... I guess it's a problem with Supabase then, it's my first time trying it out
Yup several times on several different DBs (SQLite, Postgres, Postgres @ Supabase)
wtf it's actually working with supabase now
bruh it stopped working wtf
I updated my schema and pushed it to Supabase with
npx prisma db push
and it's not working anymore???
why what how huhyep
this is a thing
happens to me a lot
oh fr? damn
Is this issue specific to supabase or a broken prisma release or something?
for me to make it work i have to click on the address bar and click enter to reload and then it works https://nexxel-has.no-friends.xyz/brave_POU2Mt9fuh.mp4
not an issue with prisma afaik
Well this doesn't address the fact that my dev server keeps crashing for no reason unfortunately
i don't remember having dev server crashes
but give it a try maybe it works lol
Yeah no dice
For some reason it seems that Prisma can't connect my Supabase DB and it's causing some weird behavior with NextAuth where it can't query the sessions/accounts/whatever from the DB
I'm not quetting any
prisma:query
logs in my console most of the time
But when I use a local Postgres DB it works finemaybe supabase is down?
Supabase Status
Welcome to Supabase's home for real-time and historical data on system performance.
yeah just saw
Yeah no recent outages
Yeah so clearly it lookss like it's some sort of issue with either Prisma or Supabase
I try to run Prisma studio on my Supabase DB and it just segfaults and dies
what node version are you on
Latest LTS
try downgrading to 16
Did a full fresh reinstall yesterday
I mean I guess I could try downgrading but to the best of my knowledge this is an issue with Supabase, I think I should maybe open a new issue in their repo...?
What the latest v16.x LTS release?
just with your node version manager do 16
I think imma try Railway and see I have any issues with their Postgres DBs
and it'll select the lts 16.x
i had the segmentation error with prisma in a nuxt app
it worked when i downgraded to 16
Huh
Alright so I installed v16.19.1 imma give it a go
It actually fucking worked lmao
but why though?
lol
i think its some prisma issue
i didn't bother opening an issue but you should
Yeah I'll try to get on that later today
tysm! @nexxel
np
Also am I missing out on any important features by using node 16?
no not really
there's some new stuff like node -w
but i don't think you'll be using that in a next.js app
What does that do?
Never used that -w flag before
it runs a file in watch mode
so like when you save it reloads
only works on .js files
i think it might be -watch
Interesting, switching back and forth between latest LTS releases of v16 and v18 shows that v16 consistently works while v18 consisntently doesn't lmao
Oh, I already got nodemon for that lol
Or the next.js dev server or whatever
another new thing is the alternative syntax to import native node packages like fs and crypto, etc
it used to
fs
or crypto
which still works but you can also now do node:fs
or node:crypto
there might be more things im missing outOh I think I've seen that in the wild before but never bothered to look up what it actually meant
I was on LTS today/last night when testing your code worked fine
This is just 𥲠wtf
certified node.js moment for taking the time to help me out too ð