Meteor._debug() - how to save the stack trace

I’ve created a function to catch the errors through Meteor._debug()

But I cannot save the value of stack variable. It is an object but there are no keys. JSON.stringify() also doesn’t work. When I do stack.toString() I can only get the first line of the stack trace. But it displays properly with console.log().

Any idea?

This is in the server

const originalMeteorDebug = Meteor._debug;
Meteor._debug = (message, stack) => {
    if (Meteor.isDevelopment) {
        console.log('===== message =====', message);
        console.log('===== stack =====', stack);

    errorLogger.error(`Server Error: ${message}`, stack.toString());

    return originalMeteorDebug.apply(this, arguments);

Here is the sample output in my admin panel

@rjdavid check out the Kadira APM code for some of the inner secrets of getting this sort of info.

I used a bunch of those tricks in this package:

Would love to perhaps generalize all the error extraction tricks into a module that multiple packages could use.,…

1 Like

Thanks, @hexsprite. I’ll take a look.

It worked. Thanks a lot.

We hate Meteor._debug (no single usage pattern)