profile
viewpoint

Ask questionsclient not receiving response after unpiping busboy from from limit event

after unpiping busboy from the limit event handler no response is received by the client, not unpiping busboy works fine but requires the remainder of the upload to be sent to the server.

unpiping and returning a response from a custom event in the same way works fine


//Don't work
file.once('limit', () => {
  req.unpipe(req.busboy)
  return res.status(413).json({
    file: filename,
    status: 413,
    message: 'file too large'
  })
})

// Work fine
filesig.on('signature', signature => {
  if (!signature.mimetype.includes(fileinfo.type)) {
    req.unpipe(req.busboy)
    return res.status(415).json({
      file: filename,
      status: 415,
      message: 'invaild filetype'
    })
  }
})
mscdex/busboy

Answer questions mscdex

I'm not sure what you mean by 'custom event', but did you try adding req.resume() after unpiping?

useful!

Related questions

Error uploading large file - Out of Memory hot 1
Busboy is expecting the Content-Type header key to lower case hot 1
how to handle exception when not any file uploaded hot 1
Github User Rank List