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 437 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
  1. module.exports = function abort (req, res, next) {
  2. // If the client aborts the connection, send an error
  3. req.once('aborted', () => {
  4. // NOTE: Node.js will also automatically set `req.aborted = true`
  5. const abortError = new Error('Client closed request')
  6. abortError.statusCode = 499
  7. abortError.code = 'ECONNRESET'
  8. // Pass the error to the Express error handler
  9. return next(abortError)
  10. })
  11. return next()
  12. }
Tip!

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

Comments

Loading...