Random fatal error without callstack



  • Hi all,
    i'm using neonious-one to constantly read an analog value from a water-pressure sensor to monitor my water tank level.

    At random i found the board blocked, and after login the popup says:

    An fatal error has occured in the program: TypeError: undefined not callable Program cannot continue.
    

    The main problem is that i don't know what cause the problem since into callstack tab i have:

    Paused outside program code, while waiting for events
    

    What i can do to undestand the root cause of the problem?



  • Somewhere your program (or low.js) is throwing and that is not being catched.

    Catch the error with process uncaughtException event (https://nodejs.org/api/process.html#process_event_uncaughtexception) and output the error's stack for more information where it is happening.



  • Thank you for the suggestion, i will add this exception handler to catch those errors.



  • Finally, I have some time to spend again on the project and as suggested I have added the following lines of code:

    require('process').on('uncaughtException', function uncaughtExceptionListener (err, origin) {
        console.error(
            `Caught exception: ${err}\n` +
            `Exception origin: ${origin}`
        );
        if (err.hasOwnProperty("Tracedata")) {
            console.error(err.Tracedata.toString());
        }
        console.trace("uncaughtException Trace");
    });
    

    But always I found something like this:

    [8:15:56 AM] Caught exception: TypeError: object required, found undefined (stack index -1)
    [8:15:56 AM] Exception origin: undefined
    [8:15:56 AM] Error: uncaughtException Trace
    [8:15:56 AM]     at uncaughtExceptionListener (/index.js:36)
    [8:15:56 AM]     at emit (lib:events:158)
    [3:08:29 AM] Caught exception: TypeError: undefined not callable
    [3:08:29 AM] Exception origin: undefined
    [3:08:29 AM] Error: uncaughtException Trace
    [3:08:29 AM]     at uncaughtExceptionListener (/index.js:36)
    [3:08:29 AM]     at emit (lib:events:158)
    

    Any way to obtain more useful information?



  • Hi !

    Can you reproduce this with low.js on the PC?

    Thank you,

    Thomas



  • Reproduce on PC I think will be a little bit difficult for me, but I will try to do some tests.

    One question:
    looking into event.js code I have noticed this piece of code commented:

    try {
        const { kExpandStackSymbol } = require('internal/util');
        const capture = {};
        Error.captureStackTrace(capture, EventEmitter.prototype.emit);
        Object.defineProperty(er, kExpandStackSymbol, {
            value: enhanceStackTrace.bind(null, er, capture),
            configurable: true
        });
    } catch (e) {}
    

    I have not understood why... may be useful to better understand where the exception is thrown?

    Thank you.



  • event.js is a file 1 to 1 copied from Node.JS. So not written by me/us.

    This code gets some data and saves it as kExpandStackSymbol of an Error object. As kExpandStackSymbol is a symbol and not a named property, this data will be used by other parts of the library code, which the user can call, I guess to get better stack traces. Not by the user direct.

    Did you actually try to print err.stack of the uncaught exception?



  • Yes, the result of console.log(err.stack) is almost the same:

    TypeError: undefined not callable
         at [anon] internal
    


  • Looking online i have found this node.js option to enable more debug info in situations like this:

    --async-stack-traces
    

    Is available on lowjs?


Log in to reply