question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unintentional catch?

See original GitHub issue

I 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:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

3reactions
swapsCAPScommented, Jun 11, 2021

FWIW switched to cron

1reaction
Wyctuscommented, Jun 11, 2021

FWIW switched to cron

Me too!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found