jai
jai3y 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 User3y ago
Message Not Public
Sign In & Join Server To View
jai
jaiOP3y ago
yup it is
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
jai
jaiOP3y 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
jai
jaiOP3y ago
this is the response
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
jai
jaiOP3y ago
no this is for the api route
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
jai
jaiOP3y ago
i don't think so, everything has been working before. just for whatever reason this recent push caused these problems
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
jai
jaiOP3y ago
ah
jai
jaiOP3y ago
Oh okay so that makes sense. the html comes when there's an error because vercel puts up this 500 page
jai
jaiOP3y 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
jai
jaiOP3y ago
an interesting thing i found is that on the deployments i get this error, it seems like vercel is hitting a cache...
jai
jaiOP3y 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 User3y ago
Message Not Public
Sign In & Join Server To View
jai
jaiOP3y ago
yes in dev and build mode
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
jai
jaiOP3y 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