Skip to content

Commit 93b7821

Browse files
committed
fix: middleware/events - check res.headerSent before attempting to send response
- Closes #18527
1 parent 10fef4d commit 93b7821

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

middleware/events.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@ router.post('/', async function postEvents (req, res, next) {
4444
throw err
4545
}
4646

47+
if (res.headersSent) {
48+
throw new Error('Cannot send http response: Hydro publish succeeded, but took too long.')
49+
}
50+
4751
return res.status(201).json(fields)
4852
} catch (err) {
4953
if (isDev) console.error(err)
50-
return res.status(502).json({})
54+
55+
if (!res.headersSent) {
56+
return res.status(502).json({})
57+
}
5158
}
5259
})
5360

0 commit comments

Comments
 (0)