#Data doesn't commit when re-throwing error
9 messages · Page 1 of 1 (latest)
Where is the try/catch? Is this a Convex action calling a mutation? when you say "the whole thing is wrapped in a try/catch" I'm not sure what that means.
Almost the entire body of the mutation is within a try/catch, but that wasn't actually helpful info - main point is that the insert that's failing is inside of a try/catch, and I'm awaiting it. When it throws, the error is logged in convex logs, but the catch doesn't execute.
Basically:
export const paginate = internalMutation({
args: {
migrationId: v.id('migrations'),
},
handler: async ({ db, scheduler }, { migrationId }) => {
try {
await db.insert('my_table', { some: 'data' }
} catch (e) {
// this never runs
await db.patch(migrationId, { status: 'error', error: e?.toString() })
throw e
}
}
})
The only thing in the console when it fails is the error. I was thinking it wasn't catching, but looking at it now it seems more likely that the log is from the rethrow.
But the patch doesn't happen, which I would expect to cause a separate error before the rethrow. Maybe the patch is failing silently?