-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
Node v18.15.0 and higher ignore --max-http-header-size #47246
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Can you include a test case? No third-party modules, just built-in modules. I'm reasonably sure the option gets passed to undici (the new http library) because we have tests that exercise the flag. |
Ok, I just create wery simple HTTP server: # server.js
const http = require("http");
const host = 'localhost';
const port = 8000;
const requestListener = function (req, res) {
res.setHeader("Content-Type", "application/json");
res.setHeader("X-FakeSize", new Array(20000).join('a'));
res.writeHead(200);
res.end("My first server!");
};
const server = http.createServer(requestListener);
server.listen(port, host, () => {
console.log(`Server is running on http://${host}:${port}`);
}); I run server
Node version used:
os
|
You can change the behavior by const { Agent, setGlobalDispatcher } = require('undici')
setGlobalDispatcher(new Agent({
maxHeaderSize: http.maxHeaderSize
})) Full code that would work for your usage. const http = require("http");
const { fetch, Agent, setGlobalDispatcher } = require('undici')
setGlobalDispatcher(new Agent({
maxHeaderSize: http.maxHeaderSize
}))
const host = 'localhost';
const port = 8000;
const requestListener = function (req, res) {
res.setHeader("Content-Type", "application/json");
res.setHeader("X-FakeSize", new Array(20000).join('a'));
res.writeHead(200);
res.end("My first server!");
};
const server = http.createServer(requestListener);
server.listen(port, host, () => {
console.log(`Server is running on http://${host}:${port}`);
fetch(`http://${host}:${port}`)
.then(function() {
console.log('normal')
process.exit(0)
})
.catch(function(err) {
console.log('error')
process.exit(1)
})
}); |
@nodejs/http if ☝️is true, isn't that a bug? |
Given it's a read-only value, I think undici can use that value as the default when creating the default Agent. Shall we move this issue to undici? |
IMHO this behaviour should be same than in older node versions. Also when user use frameworks like NextJS, then is unexpected when there is no simple way change this value. |
Just got this error in NextJS after upgrading to its recent version. Is there any way to apply the workaround to it? |
My two cents here, @mcollina's #47246 (comment) makes a lot of sense to me. In newer versions of Node.js, I consider I don't mind if it's a different flag, even something like |
For this particular problem, users can use It seems @mcollina is also in agreement; so lets ship it 🚢 |
I believe it just the matter of will someone willing to open PR to update |
Hi everyone, this has shipped in Node.js, you can upgrade, and will be able to set this flag, I believe the issue can be closed @havran. |
Version
v18.15.0 and v19.8.1
Platform
Linux FESK-LTP0007 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux (Ubuntu 22.04)
Subsystem
No response
What steps will reproduce the bug?
I use urql in my NextJS application, to communicate with backend CMS. For some query CMS send extra large headers with response (around 22kb).
I use node 18 as runner for project where I use URQL library to GraphQL request to backend CMS, but there I get console error:
I investigate and I found solution to set http header size by using environment:
NODE_OPTIONS=--max-http-header-size=32768
This seems to be ignored for Node version 18 and higher (I also try node 19). On Node 16, this environment variable solve error.
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
I see error message:
Additional information
No response
The text was updated successfully, but these errors were encountered: