Title: http: `appendHeader()` mutates the array passed to `setHeader()` · Issue #67526 · nodejs/node · GitHub
Open Graph Title: http: `appendHeader()` mutates the array passed to `setHeader()` · Issue #67526 · nodejs/node
X Title: http: `appendHeader()` mutates the array passed to `setHeader()` · Issue #67526 · nodejs/node
Description: Version v26.13.1 Platform 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? const http = require('node:http...
Open Graph Description: Version v26.13.1 Platform 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 ...
X Description: Version v26.13.1 Platform 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 ...
Opengraph URL: https://github.com/nodejs/node/issues/67526
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"http: `appendHeader()` mutates the array passed to `setHeader()`","articleBody":"### Version\n\nv26.13.1\n\n### Platform\n\n```text\nDarwin 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\n```\n\n### Subsystem\n\nhttp, http2\n\n### What steps will reproduce the bug?\n\n```js\nconst http = require('node:http');\n\nconst opts = { method: 'GET', httpVersionMajor: 1, httpVersionMinor: 1 };\n\nconst res = new http.ServerResponse(opts);\nconst cookies = ['a=1'];\nres.setHeader('Set-Cookie', cookies);\nres.appendHeader('Set-Cookie', 'b=2');\nconsole.log(cookies); // orig array is modified\n\nconst res2 = new http.ServerResponse(opts);\nres2.setHeader('Set-Cookie', Object.freeze(['a=1']));\nres2.appendHeader('Set-Cookie', 'b=2'); // throws an error trying to mutate the frozen array in previous line\n```\n\n### How often does it reproduce? Is there a required condition?\n\nThis bug occurs anytime an array is passed to `setHeader()` or to `appendHeader()` on a header that isn't set yet.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nFrom 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.\n\n### What do you see instead?\n\n```\n[ 'a=1', 'b=2' ]\nTypeError: Cannot add property 1, object is not extensible\n```\n\n### Additional information\n\nI have a fix and am opening a PR momentarily.","author":{"url":"https://github.com/Ethan-Arrowood","@type":"Person","name":"Ethan-Arrowood"},"datePublished":"2026-11-16T19:11:52Z","url":"https://github.com/nodejs/node/issues/67526"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8456f9e5-bf1d-3c4c-ad40-feb107580649 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 94EE:128099:85DD00:B2B6BE:6B063447 |
| html-safe-nonce | 2dc0e6aa552faf690888055cfc26ece0fadc7df44d4d46297d448f6f5873ec2b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NEVFOjEyODA5OTo4NUREMDA6QjJCNkJFOjZCMDYzNDQ3IiwidmlzaXRvcl9pZCI6IjI5Nzg2NjM0MDc1OTI4MTM2MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 148963c5e7c4cd93efa1320f7ca14f735d31d08f88cce1796d7bf372262b5b22 |
| hovercard-subject-tag | issue:6428703054 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/67526/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9923a8d87b03fa47e81fde2630efdd2ff02b28af54d0ea2554302e39a34f245a/nodejs/node/issues/67526 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9923a8d87b03fa47e81fde2630efdd2ff02b28af54d0ea2554302e39a34f245a/nodejs/node/issues/67526 |
| og:image:alt | Version v26.13.1 Platform 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Ethan-Arrowood |
| hostname | github.com |
| expected-hostname | github.com |
| None | c3584c853cd39700ecff6e2cf8364295ffdb5313e571046c41cd2479270f7df0 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9eb3bb1597d09170a5f282cd38ae376dee1a5ec1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width