erquhart
erquhart17mo ago

Printing a stack trace in convex runtime

I'm trying to catch an error from a mutation but still log the stack trace. It looks like the stack property isn't present on the error object, and err.trace() just gets the location of the catch.
} catch (e) {
await db.patch(migration._id, { status: 'error', error: e?.toString() })
console.error(e) // message only (as expected)
console.trace() // traces to the catch, one line deep
console.error(e.stack) // empty string
}
} catch (e) {
await db.patch(migration._id, { status: 'error', error: e?.toString() })
console.error(e) // message only (as expected)
console.trace() // traces to the catch, one line deep
console.error(e.stack) // empty string
}
5 Replies
Indy
Indy17mo ago
Interesting. Unless someone else from the team chimes in about some wrinkle I'm not aware of, seems like we could do better here. I filed an internal task.
lee
lee17mo ago
@erquhart this should be fixed now. Error.stack has the same format as in Chrome
erquhart
erquhartOP17mo ago
Oh, nice! Will update and check it out
lee
lee17mo ago
great! thanks for reporting. the stack trace should work with npm packages like 'error-stack-parser' if you want a structured stack trace object
erquhart
erquhartOP17mo ago
hadn't heard of that, will def check out

Did you find this page helpful?