jaiv
jaiv2y ago

Queries break when in production on Vercel; work on localhost

The query is called like this:
const { data } = api.useQuery(["user.!getCount"], {
refetchInterval: interval * 1000,
onSuccess: () => ...
}
const { data } = api.useQuery(["user.!getCount"], {
refetchInterval: interval * 1000,
onSuccess: () => ...
}
every query works on localhost, but once it's deployed to Vercel they all give this same error
19 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jaiv
jaiv2y ago
yup it is
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jaiv
jaiv2y ago
hm true. and that does happen sometimes if it has an error. it returns the html from _document.tsx. i thought it was happening every time but when it's not having an error it only returns the json from trpc so i never looked into it
jaiv
jaiv2y ago
this is the response
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jaiv
jaiv2y ago
no this is for the api route
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jaiv
jaiv2y ago
i don't think so, everything has been working before. just for whatever reason this recent push caused these problems
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jaiv
jaiv2y ago
ah
jaiv
jaiv2y ago
Oh okay so that makes sense. the html comes when there's an error because vercel puts up this 500 page
jaiv
jaiv2y ago
i found a commit where it all works, the one right after is what has things break. later today ill look at the difference
jaiv
jaiv2y ago
an interesting thing i found is that on the deployments i get this error, it seems like vercel is hitting a cache...
jaiv
jaiv2y ago
maybe since it's returning a page idk yea i have no clue, nothing really changed from the commit that worked to the commit that broke it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jaiv
jaiv2y ago
yes in dev and build mode
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
jaiv
jaiv2y ago
not oss if i'm stuck on this though i could make some repo @oscartbeaumont after more debugging I found that the error was being caused by not setting up an env variable on vercel