#Printing a stack trace in convex runtime

6 messages · Page 1 of 1 (latest)

north tundra
#

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
    }
buoyant schooner
#

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.

proud moth
#

@north tundra this should be fixed now. Error.stack has the same format as in Chrome

north tundra
#

Oh, nice!

#

Will update and check it out

proud moth
#

great! thanks for reporting. the stack trace should work with npm packages like 'error-stack-parser' if you want a structured stack trace object