I don't understand... Is it me or is this a bug in node?
This is fine as expected:
const a = new Promise((resolve, reject) => {
setTimeout(() => reject('timeout'), 1000);
});
a.catch(console.log);
And this is throwing a warning:
const a = new Promise((resolve, reject) => {
setTimeout(() => reject('timeout'), 1000);
});
a.then(console.log);
a.catch(console.log);
I get
timeout
(node:40463) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): timeout
(node:40463) [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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…