You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using Express and Body-Parser middleware, but I have debugged it inside, indicating that the issue is in the internal messaging between master (primary alias) to workers. The expected size of the body is less than the received size (after chunk aggregation).
The inequality happens ONLY with cluster mode enabled, if I am not using it, it is just working (without touching anything else).
I have tried several encodings to make sure it is not related - and got the same on every type of encoding.
95KB in body example (using application/json type):
The chunks in the parser without cluster mode - 65KB, 30KB
The chunks in the parser with cluster mode - 65KB, 2KB
Client ALWAYS showing the correct Content Length
Please direct me which more information you would like to get.
Saw a PR that was solving something similar: #13778
Thanks
How often does it reproduce? Is there a required condition?
constcluster=require('node:cluster');consthttp=require('node:http');constprocess=require('node:process');process.on('beforeExit',code=>{console.log(process.pid,'exited with',code)})if(cluster.isPrimary){console.log(`Primary ${process.pid} is running`);cluster.fork();}else{// Workers can share any TCP connection// In this case it is an HTTP serverhttp.createServer((req,res)=>{console.log(process.pid,'got request')letreqBodyLen=0req.on('data',chunk=>{reqBodyLen+=chunk.length})req.on('end',()=>{console.log(reqBodyLen)res.writeHead(200);res.end('hello world\n');})}).listen(8082);console.log(`Worker ${process.pid} started`);}
I ran up code adapted from the example in doc, and sent a serval MB request, everything worked well :)
I'm using the latest node.
Version
v16.17.1
Platform
20.04.1-Ubuntu x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Send POST / PUT / PATCH API with Content-Length that is bigger than 80KB running with Cluster Mode (using the standard cluster mode configuration as described: https://nodejs.org/dist/latest-v16.x/docs/api/cluster.html)
I was using Express and Body-Parser middleware, but I have debugged it inside, indicating that the issue is in the internal messaging between master (primary alias) to workers. The expected size of the body is less than the received size (after chunk aggregation).
The inequality happens ONLY with cluster mode enabled, if I am not using it, it is just working (without touching anything else).
I have tried several encodings to make sure it is not related - and got the same on every type of encoding.
95KB in body example (using application/json type):
Client ALWAYS showing the correct Content Length
Please direct me which more information you would like to get.
Saw a PR that was solving something similar: #13778
Thanks
How often does it reproduce? Is there a required condition?
Always.
As mentioned above:
Send POST / PUT / PATCH API with Content-Length that is bigger than 80KB running with Cluster Mode (using the standard cluster mode configuration as described: https://nodejs.org/dist/latest-v16.x/docs/api/cluster.html)
I have ran it using express and the default body-parser (that uses raw-body lib behind)
What is the expected behavior?
Cluster mode should work the same as without Cluster mode
What do you see instead?
The total received chunks in the worker is different than what I see from client - only in cluster mode, while without it is the same
Additional information
No response
The text was updated successfully, but these errors were encountered: