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
The error appears when tries to set more than 3 cookies per request. It loses context during the execution
Stacktrace:
TypeError: Cannot read properties of undefined (reading 'headers_len')
at /usr/local/lib/node_modules/unit-http/http_server.js:157:13
at Array.forEach (<anonymous>)
at ServerResponse._removeHeader (/usr/local/lib/node_modules/unit-http/http_server.js:156:15)
at ServerResponse.setHeader (/usr/local/lib/node_modules/unit-http/http_server.js:89:14)
at ServerResponse.header (/app/node_modules/express/lib/response.js:684:10)
at ServerResponse.append (/app/node_modules/express/lib/response.js:645:15)
at res.cookie (/app/node_modules/express/lib/response.js:777:8)
at file:///app/index.mjs:7:9
at Layer.handleRequest (/app/node_modules/router/lib/layer.js:152:17)
at next (/app/node_modules/router/lib/route.js:157:13)
Expected Behavior
All cookies should be set without any issues
Steps to Reproduce the Bug
The standard guidelines is enough to reproduce that bug
index.mjs
import express from 'express'
const app = express();
app.get('/', (req, res) => {
res.cookie('first', 'cookie', { maxAge: 900000, httpOnly: true })
res.cookie('second', 'cookie', { maxAge: 900000, httpOnly: true })
res.cookie('third', 'cookie', { maxAge: 900000, httpOnly: true })
// ^^^^^ error appears here
res.send('Hello, Express on Unit!')
})
app.listen(8080, () => {
console.log(`Node server is listening on port 8080!`);
});
But just in case i'll provide other files as well
config.json
It fixes losing context in response in case when here 3 or more headers with the same name.
The prev implementation used to use foreach function which uses local lexical environment and did not find this.headers_len localy, which causes crash of the http server module. It was replaced to for loop in order to make access for this.headers_len variable and improve performance of calculation
Closes: nginx#1621
ac000
pushed a commit
to skokalin/unit
that referenced
this issue
May 28, 2025
It fixes losing context in response in cases when there are 2 or more
headers with the same name. The prev implementation used to use foreach
function which uses local lexical environment and did not find
this.headers_len locally, which causes crash of the http server module.
It was replaced with a for loop in order to make access for this.headers_len
variable and improve performance of calculation.
Closes: nginx#1621
Signed-off-by: Andrew Clayton <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Bug Overview
The error appears when tries to set more than 3 cookies per request. It loses context during the execution
Stacktrace:
Expected Behavior
All cookies should be set without any issues
Steps to Reproduce the Bug
The standard guidelines is enough to reproduce that bug
index.mjs
But just in case i'll provide other files as well
config.json
package.json
docker-compose.yml
then exec:
docker compose up
open browser: http://localhost:8081
Environment Details
Additional Context
No response
The text was updated successfully, but these errors were encountered: