Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

abort.js 564 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  1. module.exports = function abort (req, res, next) {
  2. // If the client aborts the connection, send an error
  3. req.once('aborted', () => {
  4. // ignore aborts from next, usually has to do with webpack-hmr
  5. if (req.path.startsWith('/_next')) {
  6. return
  7. }
  8. // NOTE: Node.js will also automatically set `req.aborted = true`
  9. const abortError = new Error('Client closed request')
  10. abortError.statusCode = 499
  11. abortError.code = 'ECONNRESET'
  12. // Pass the error to the Express error handler
  13. return next(abortError)
  14. })
  15. return next()
  16. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...