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
{{ message }}
Repository navigation
http: appendHeader() mutates the array passed to setHeader() #67526
Darwin 27.2.0 Darwin Kernel Version 27.2.0: Wed Oct 14 23:44:56 PDT 2026; root:xnu-13432.41.4~25/RELEASE_ARM64_T6041 arm64
Subsystem
http, http2
What steps will reproduce the bug?
consthttp=require('node:http');constopts={method: 'GET',httpVersionMajor: 1,httpVersionMinor: 1};constres=newhttp.ServerResponse(opts);constcookies=['a=1'];res.setHeader('Set-Cookie',cookies);res.appendHeader('Set-Cookie','b=2');console.log(cookies);// orig array is modifiedconstres2=newhttp.ServerResponse(opts);res2.setHeader('Set-Cookie',Object.freeze(['a=1']));res2.appendHeader('Set-Cookie','b=2');// throws an error trying to mutate the frozen array in previous line
How often does it reproduce? Is there a required condition?
This bug occurs anytime an array is passed to setHeader() or to appendHeader() on a header that isn't set yet.
What is the expected behavior? Why is that the expected behavior?
From the code example, cookies stays [ 'a=1' ], and appending to a frozen array works. appendHeader() should change the response's headers, not the array I passed in. setHeader() accepts a frozen array, so a later appendHeader() shouldn't throw either.
What do you see instead?
[ 'a=1', 'b=2' ]
TypeError: Cannot add property 1, object is not extensible
Activity
http,http2: copy header arrays in setHeader