How do you know where the raw promise occurred?

Quick introduction: I understand Promises, I understand decision and rejection. It's not a question.

(node:14104) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: "callback" argument must be a function
(node:14104) [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.\

I understand that somewhere in my code, the callback argument, which should be a function, is not. This is not my question either.

How to find the line of code where the raw deviation occurred?

+4
source share
1 answer

node unhandledRejection event should solve your secret:

process.on('unhandledRejection', (reason, promise) => {
    console.warn('Unhandled promise rejection:', promise, 'reason:', reason.stack || reason);
});

https://repl.it/I3JJ/2

+6
source

Source: https://habr.com/ru/post/1678411/


All Articles