Home > Back-end >  App was killed with setTimeout callback func on express.js
App was killed with setTimeout callback func on express.js

Time:02-28

I have short question.

router.get('/', function(req, res, next) {
  throw new Error('123')
  res.send('respond with a resource');
});

When I call this snippet on express project. It throw error what I expected.

But

router.get('/', function(req, res, next) {
  setTimeout(() => {
    throw new Error('123')
  }, 1000)
  res.send('respond with a resource');
});

With this code express process killed with Command failed with exit code 1. this message.

What keywords should I study is? What am I missing?

Thank you.

CodePudding user response:

1.The default error handler http://expressjs.com/en/guide/error-handling.html

2.callback error handler try/catch issues with nested functons in javascript

  • Related