mscdex / busboy

A streaming parser for HTML form data for node.js
MIT License
2.84k stars 213 forks source link

Filesize limit fails unless is a rounded integer #329

Closed shanehoban closed 4 months ago

shanehoban commented 1 year ago

Was just using arbitrary values for testing the file size limit and it always had truncate set to false - and the limit event on file was never getting hit. Was very confusing until I rounded the number.

Example that fails:

const bb = Busboy({
  headers: event.node.req.headers,
  limits: {
    fileSize: (0.005 * 1024 * 1024)
  }
})

Example that works:

const bb = Busboy({
  headers: event.node.req.headers,
  limits: {
    fileSize: Math.floor(0.005 * 1024 * 1024)
  }
})

Maybe round this on the busboy end to save morons like me time?