New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bodyReader does not work with both gunzip and maxBodySize #1785
Comments
This bug extends beyond just the example given here. It also affects requests that specify a content-type and a content-encoding of gzip, but have no request body. User requests with invalid gzip data in the request body should result in a 400, not a 500. What would it take to update the PR to include this other use case, and what would it take to land it? I'm prepared to help with this if needed. Minimum reproduction of other use case: const restify = require('restify')
const server = restify.createServer()
server.use(restify.plugins.bodyParser())
server.get('/', async (req, res) => res.send(200, 'ok'))
server.listen('8080') $ curl -v -H 'Content-encoding: gzip' -H 'Content-type: json' http://localhost:8080/
* Trying [::1]:8080...
* Connected to localhost (::1) port 8080
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/8.4.0
> Accept: */*
> Content-encoding: gzip
> Content-type: json
>
* Empty reply from server
* Closing connection
curl: (52) Empty reply from server $ node server.js
(node:85775) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
node:events:492
throw er; // Unhandled 'error' event
^
Error: unexpected end of file
at Zlib.zlibOnError [as onerror] (node:zlib:189:17)
Emitted 'error' event on Gunzip instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -5,
code: 'Z_BUF_ERROR'
}
Node.js v20.10.0 |
The |
Bug Report
bodyReader
plugin setup withmaxBodySize
when called withContent-Encoding: gzip
with body size over the body limit causes zlib buffer error and eventually stops process.Restify Version
8.3.2
Node.js Version
10.14.2
Expected behaviour
Return "413 Body Too Long". Same behaviour as for not gzipped content.
Actual behaviour
server is down with error:
Repro case
Cause
bodyReader
done
handler function is not triggered when gunzip transformer emits error due to incomplete buffer when it is incomplete because maxBodySize limit was reached.Are you willing and able to fix this?
Yes. PR is on the way.
The text was updated successfully, but these errors were encountered: