Skip to content

Commit 0f3a861

Browse files
authored
Merge pull request #12031 from github/repo-sync
repo sync
2 parents c1202c7 + fab5bef commit 0f3a861

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

lib/handle-exceptions.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@ process.on('uncaughtException', async (err) => {
99
}
1010

1111
console.error(err)
12-
await FailBot.report(err)
12+
try {
13+
await FailBot.report(err)
14+
} catch (failBotError) {
15+
console.warn('Even sending the uncaughtException error to FailBot failed!')
16+
console.error(failBotError)
17+
}
1318
})
1419

1520
process.on('unhandledRejection', async (err) => {
1621
console.error(err)
17-
await FailBot.report(err)
22+
try {
23+
await FailBot.report(err)
24+
} catch (failBotError) {
25+
console.warn('Even sending the unhandledRejection error to FailBot failed!')
26+
console.error(failBotError)
27+
}
1828
})

middleware/events.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@ router.post('/', async function postEvents(req, res, next) {
1919
return res.status(400).json(isDev ? ajv.errorsText() : {})
2020
}
2121

22+
res.json({})
23+
2224
if (req.hydro.maySend()) {
23-
// intentionally don't await this async request
24-
// so that the http response afterwards is sent immediately
25-
req.hydro.publish(hydroNames[fields.type], omit(fields, OMIT_FIELDS)).catch((e) => {
26-
if (isDev) console.error(e)
27-
})
25+
await req.hydro.publish(hydroNames[fields.type], omit(fields, OMIT_FIELDS))
2826
}
29-
30-
return res.status(200).json({})
3127
})
3228

3329
export default router

0 commit comments

Comments
 (0)