2020-09-27 15:10:11 +03:00
|
|
|
// This module is for testing our handling of uncaught async rejections on incoming requests
|
|
|
|
|
2021-03-11 04:12:41 +03:00
|
|
|
// IMPORTANT: Leave this function as `async` even though it doesn't need to be!
|
2021-07-15 00:35:01 +03:00
|
|
|
export default async function triggerError(req, res, next) {
|
2021-03-11 04:12:41 +03:00
|
|
|
// IMPORTANT:
|
|
|
|
// Do NOT wrap this method's contents in the usual `try-catch+next(error)`
|
|
|
|
// pattern used on async middleware! This is an intentional omission!
|
|
|
|
|
2020-09-27 15:10:11 +03:00
|
|
|
// prevent this from being used in production
|
2021-09-01 00:49:39 +03:00
|
|
|
if (process.env.NODE_ENV === 'production' && process.env.HEROKU_PRODUCTION_APP) return next()
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2021-01-05 19:07:27 +03:00
|
|
|
throw new Error('Intentional error')
|
2020-09-27 15:10:11 +03:00
|
|
|
}
|