body-parser icon indicating copy to clipboard operation
body-parser copied to clipboard

Parser does not work in serverless environment

Open czarny opened this issue 9 months ago • 0 comments

Environment information

Version: "body-parser: 1.20.3 "express": "^5.1.0", "serverless-http": "^3.2.0",

Platform: Service is deployed to as AWS Lambda.

Any other relevant information:

Latest express release uses body-parser which uses on-finished to determine if body should be parsed.

The on-finished checks socket.readable property to determine if request is finished (https://github.com/jshttp/on-finished/blob/master/index.js#L76).

The serverless-http sets readable to false (https://github.com/dougmoscrop/serverless-http/blob/master/lib/request.js#L9) when creating request object for express.

This causes that body-parser skips body parsing (https://github.com/expressjs/body-parser/blob/master/lib/types/json.js#L87) because request is considered finished.

czarny avatar Apr 15 '25 13:04 czarny