mennov_
mennov_2mo ago

skip - works in dev not prod

It feels simple, but I can seem to solve it. I use skip if the userId isn’t defined. Works in dev, errors in prod - seems to be calling the function even thought skip is defined. Simplified it down to: const user = useQuery(api.users.getUser, “skip”); It works against dev, but when built and pushed to prod, “skip” no longer seems to apply. (And I’ve used skip elsewhere and it does seem to work). Latest 1.18.2 convex/react library.
5 Replies
Convex Bot
Convex Bot2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
lee
lee2mo ago
that's odd; there are very few differences between dev and prod convex environments, and "skip" is entirely client-side so it shouldn't interact with the deployment at all. Could you share a bit more of the surrounding code? since this sounds like it might be an auth issue, note there are two other suggested solutions (besides skip) for auth not being available in a query yet https://docs.convex.dev/auth/debug#ctxauthgetuseridentity-returns-null-in-a-query
Debugging Authentication | Convex Developer Hub
You have followed one of our authentication guides but something is not working.
mennov_
mennov_OP2mo ago
Here is a sample page
function RouteComponent() {
const hello = useQuery(api.testskip.hello, "skip");
return (
<div>
This page should load without error
{JSON.stringify({ type: typeof hello, hello })}
</div>
);
}
function RouteComponent() {
const hello = useQuery(api.testskip.hello, "skip");
return (
<div>
This page should load without error
{JSON.stringify({ type: typeof hello, hello })}
</div>
);
}
When running as bun run dev, it will correctly remain undefined. When running bun run build followed by bunx serve -s dist -l 5173 it will try to execute the query every time.
import { v } from "convex/values";
import { query } from "./_generated/server";

export const hello = query({
args: {
name: v.string(),
},
async handler(ctx, { name }) {
if (ctx) {
true;
}
return `Hello, ${name}!`;
},
});
import { v } from "convex/values";
import { query } from "./_generated/server";

export const hello = query({
args: {
name: v.string(),
},
async handler(ctx, { name }) {
if (ctx) {
true;
}
return `Hello, ${name}!`;
},
});
I did build this in a brand new repo as well, and didn't run into an issue there. Issue seems to be in my existing repo with many other functions.
erquhart
erquhart2mo ago
Can you try logging something, like in that line right after const hello =, and make sure the log prints in the bun run build version? This really seems like old bundled code hanging around.
mennov_
mennov_OP5w ago
I tried that, and it made no difference. Ended up blowing away the bun lock file, did a new bun install, and committed the new bun lockfile. After that the production build was successful.

Did you find this page helpful?