Closed berekuk closed 2 years ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated |
---|---|---|---|
metaforecast | ✅ Ready (Inspect) | Visit Preview | Apr 22, 2022 at 8:51PM (UTC) |
No, that's not it, it still responds with 500. But only on Vercel, it works on my machine even if I point it to the prod DB. Weird.
Oh.
ERROR ReferenceError: prisma is not defined
at getFrontpage (/var/task/.next/server/pages/api/graphql.js:75:23)
Which should've been caught by typescript... except that there's this code from Prisma's "Best practice for dev" page which recommends putting prisma in global
, but in dev only. Ugh.
global.prisma
to global._prisma
to avoid future issues like this
(continuing from #67, turns out GH doesn't allow reopening PRs...)
Ok, I'm not sure what happened, but #67 broke prod. I'm opening this just to leave this postmortem note, and to check the code before merging to master.
My original approach went like this:
Prisma generated a weird query, which I noticed but decided that it's not a big deal (notice the triple negations):
It worked on my machine for my local dev db but collapsed in prod.
Anyway, when I went to debug it I noticed that it also wasn't keeping the random order because I selected questions which had frontpage ids, which sorted the questions in the natural questions order.
So now I'm doing it in reverse: select for frontpage ids and ask Prisma to add questions data to it.
This causes two queries instead of one:
But it shouldn't be a problem.