Unintentional catch?
See original GitHub issueI would like to let my program crash when a promise throws an error. It seems like promises are being caught by node-cron.
const cron = require('node-cron')
process.once('unhandledRejection', (reason) => {
console.log('unhandledRejection', reason)
throw reason
})
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms))
const willThrow = async () => {
await sleep(50)
throw new Error('Ouch!')
}
cron.schedule('*/1 * * * * *', () => willThrow())
const fail = async () => {
await sleep(2000)
throw new Error('FAIL!')
}
fail()
output
▶ node node-cron-throw.js
Error: Ouch!
at willThrow (/scripts/node-cron-throw.js:12:9)
Error: Ouch!
at willThrow (/scripts/node-cron-throw.js:12:9)
unhandledRejection Error: FAIL!
at fail (/scripts/node-cron-throw.js:19:9)
/scripts/node-cron-throw.js:5
throw reason
^
Error: FAIL!
at fail (/scripts/node-cron-throw.js:19:9)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Bycatch - Wikipedia
Bycatch (or by-catch), in the fishing industry, is a fish or other marine species that is caught unintentionally while fishing for specific species...
Read more >Accidental Catch | Smithsonian Ocean
And it's a big problem. A 2003 study found that 300,000 birds are being killed each year by fisheries as bycatch, of which...
Read more >Bycatch; incidental catch; accidental catch - ESCWA
The term “bycatch” is widely used to refer to that part of the catch unintentionally captured during a fishing operation, in addition to...
Read more >What is Bycatch? Understanding and Preventing Fishing ...
Bycatch occurs because modern fishing gear is very efficient, often covers an extensive area, and can be highly unselective—it catches not only the...
Read more >What is bycatch? | NOAA Fisheries
For NOAA Fisheries, bycatch refers to“discarded catch of marine species and unobserved mortality due to a direct encounter with fishing vessels and gear.”...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FWIW switched to cron
Me too!