Skip to content

UnhandledPromiseRejectionWarning #24

Open
@mnemo70

Description

@mnemo70

Hi, thanks for your API module. I'm trying to write Node-RED nodes around it and on the first call to setProfile() it works, but a second call then raises this warning on the Node-RED console:

(node:15613) UnhandledPromiseRejectionWarning: #<ErrorEvent>
    at emitUnhandledRejectionWarning (internal/process/promises.js:151:15)
    at processPromiseRejections (internal/process/promises.js:211:11)
    at processTicksAndRejections (internal/process/task_queues.js:98:32)
(node:15613) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15613) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    at emitDeprecationWarning (internal/process/promises.js:161:11)
    at processPromiseRejections (internal/process/promises.js:213:13)
    at processTicksAndRejections (internal/process/task_queues.js:98:32)

I suspect that the calls to _request() in fetchMetrics() and setValues() trigger this warning or internal exceptions because I don't see any exception handling in there.

I'm using try/catch around the setProfile() call in my node, which should be okay. The catch does not get triggered.

if(newProfile >= 0) {
    (async () => {
        try {
            await client.setProfile(newProfile);
        }
        catch(e) {
            msg.payload = 'Exception setting profile to: ' + newProfile + ' Ex=' + e.message;
        }
    })()

Since I'm not an expert in Node.js, can you shed a light on this, please? Please excuse me if I'm totally wrong. :-)

Kind regards,
Thomas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions