Nicolas Quiroz
Nicolas Quiroz2mo ago

Error getting version, preloaded query not found

I'm starting to think it is a bug. I have a preload query that I'm using like this:
'use client';

import { api } from '@repo/backend/convex/_generated/api';
import { Input } from '@repo/design-system/components/ui/input';
import { Label } from '@repo/design-system/components/ui/label';
import { Textarea } from '@repo/design-system/components/ui/textarea';
import { useTranslations } from '@repo/internationalization';
import { type Preloaded, useMutation, usePreloadedQuery } from 'convex/react';

interface SubmissionEditFormProps {
preloadedSubmission: Preloaded<typeof api.submissionsQueries.obtainSubmission>;
}

export function SubmissionEditForm({
preloadedSubmission,
}: SubmissionEditFormProps) {
const t = useTranslations('web.submissions.edit.form');
const submission = usePreloadedQuery(preloadedSubmission);
const updateSubmission = useMutation(api.submissionMutations.updateSubmissionName);
const updateSubmissionName = async (name: string) => {
if (!submission) {
return;
}
await updateSubmission({
submissionId: submission._id,
name,
});
};

if (!submission) {
return (
<div className="py-12 text-center">
<p className="text-gray-500">{t('errors.notFound')}</p>
</div>
);
}

return ...
}
'use client';

import { api } from '@repo/backend/convex/_generated/api';
import { Input } from '@repo/design-system/components/ui/input';
import { Label } from '@repo/design-system/components/ui/label';
import { Textarea } from '@repo/design-system/components/ui/textarea';
import { useTranslations } from '@repo/internationalization';
import { type Preloaded, useMutation, usePreloadedQuery } from 'convex/react';

interface SubmissionEditFormProps {
preloadedSubmission: Preloaded<typeof api.submissionsQueries.obtainSubmission>;
}

export function SubmissionEditForm({
preloadedSubmission,
}: SubmissionEditFormProps) {
const t = useTranslations('web.submissions.edit.form');
const submission = usePreloadedQuery(preloadedSubmission);
const updateSubmission = useMutation(api.submissionMutations.updateSubmissionName);
const updateSubmissionName = async (name: string) => {
if (!submission) {
return;
}
await updateSubmission({
submissionId: submission._id,
name,
});
};

if (!submission) {
return (
<div className="py-12 text-center">
<p className="text-gray-500">{t('errors.notFound')}</p>
</div>
);
}

return ...
}
The query file convex/submissions.ts is like follows:
// unrelevant imports
import type { DataModel } from './_generated/dataModel';
import {
mutation,
type QueryCtx,
query,
} from './_generated/server';
import {
findSubmissionById,
} from './model/submissions';

// ... unrelevant code (i think)


export const obtainSubmission = queryWithRLS({
args: {
submissionId: v.id('submissions'),
},
handler: async (ctx, args) => {
return await findSubmissionById(ctx, args);
},
});
// unrelevant imports
import type { DataModel } from './_generated/dataModel';
import {
mutation,
type QueryCtx,
query,
} from './_generated/server';
import {
findSubmissionById,
} from './model/submissions';

// ... unrelevant code (i think)


export const obtainSubmission = queryWithRLS({
args: {
submissionId: v.id('submissions'),
},
handler: async (ctx, args) => {
return await findSubmissionById(ctx, args);
},
});
For some reason, the database returns null on the get, but I 'm completely sure the ID exists (I checked with console logs and querying the database from the dashboard).
2 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!
Nicolas Quiroz
Nicolas QuirozOP2mo ago
I'm getting errors in convex functions like:
Error getting version: [TypeError: dynamic module import unsupported]
Error getting version: [TypeError: dynamic module import unsupported]
Turn's out it's not an issue of the preload itself, seems to be something else.

Did you find this page helpful?