Title: net: onread can modify buffers made immutable after registration · Issue #67397 · nodejs/node · GitHub
Open Graph Title: net: onread can modify buffers made immutable after registration · Issue #67397 · nodejs/node
X Title: net: onread can modify buffers made immutable after registration · Issue #67397 · nodejs/node
Description: Version v28.0.0-pre Platform macos 26.6.2, arm64 (darwin 25.6.0) Subsystem net What steps will reproduce the bug? save this as repro.cjs and run with: ./node --js-immutable-arraybuffer repro.cjs const net = require('node:net'); const ser...
Open Graph Description: Version v28.0.0-pre Platform macos 26.6.2, arm64 (darwin 25.6.0) Subsystem net What steps will reproduce the bug? save this as repro.cjs and run with: ./node --js-immutable-arraybuffer repro.cjs co...
X Description: Version v28.0.0-pre Platform macos 26.6.2, arm64 (darwin 25.6.0) Subsystem net What steps will reproduce the bug? save this as repro.cjs and run with: ./node --js-immutable-arraybuffer repro.cjs co...
Opengraph URL: https://github.com/nodejs/node/issues/67397
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"net: onread can modify buffers made immutable after registration","articleBody":"### Version\n\nv28.0.0-pre\n\n### Platform\n\n```text\nmacos 26.6.2, arm64 (darwin 25.6.0)\n```\n\n### Subsystem\n\nnet\n\n### What steps will reproduce the bug?\n\nsave this as repro.cjs and run with:\n\n```sh\n./node --js-immutable-arraybuffer repro.cjs\n```\n\n```js\nconst net = require('node:net');\n\nconst server = net.createServer((socket) => socket.end('test'));\nserver.listen(0, '127.0.0.1', () => {\n const buffer = new Uint8Array(4);\n let immutable;\n const socket = net.connect({\n host: '127.0.0.1',\n port: server.address().port,\n onread: {\n buffer,\n callback(nread) {\n console.log('bytes read:', nread);\n console.log('old view length:', buffer.byteLength);\n console.log('immutable:', immutable.immutable);\n console.log('after:', [...new Uint8Array(immutable)]);\n socket.end();\n },\n },\n });\n socket.on('close', () => server.close());\n immutable = buffer.buffer.transferToImmutable();\n console.log('before:', [...new Uint8Array(immutable)]);\n});\n```\n\n### How often does it reproduce? Is there a required condition?\n\nalways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nafter transferToImmutable() succeeds, incoming data must not change\nthe returned arraybuffer's bytes.\n\n### What do you see instead?\n\n```text\nbefore: [ 0, 0, 0, 0 ]\nbytes read: 4\nold view length: 0\nimmutable: true\nafter: [ 116, 101, 115, 116 ]\n```\n\nthe old view is detached, but incoming data still changes the new\nimmutable arraybuffer.\n\n### Additional information\n\ni found this while working on #67394. that pr checks buffers when they\nare supplied, so it doesn't catch a transfer after registration.\n\nthe native listener keeps using the cached address:\n[UseUserBuffer](https://github.com/nodejs/node/blob/2aef805afe091f0c6e28b756cf85b97b8b6ab87f/src/stream_base.cc#L162)\n[OnStreamAlloc](https://github.com/nodejs/node/blob/2aef805afe091f0c6e28b756cf85b97b8b6ab87f/src/stream_base.cc#L769)\n\nrelated: #66346\n\ni'm planning to work on a fix.","author":{"url":"https://github.com/fatihguzeldev","@type":"Person","name":"fatihguzeldev"},"datePublished":"2026-11-10T22:00:44Z","url":"https://github.com/nodejs/node/issues/67397"}
| 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:5fbd90f2-b815-de26-49dc-ad823f9fc142 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 832A:3CBF9:72C0B5:943F1D:6B0626BC |
| html-safe-nonce | 1edd16a8aa12fe059d5143b4b14543d9e18c3908af0c8f38252deec56a40e14f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzJBOjNDQkY5OjcyQzBCNTo5NDNGMUQ6NkIwNjI2QkMiLCJ2aXNpdG9yX2lkIjoiNDUzOTQwMDY4OTgzOTEyMjEwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f275b2ab8be00350dd766f24d6469831f8996d916c1f36278a65355cc92dd9aa |
| hovercard-subject-tag | issue:6316740055 |
| 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/67397/issue_layout |
| twitter:image | https://opengraph.githubassets.com/47b0da639c2d4d71edfd1b421a099335817cb0284f95a70ce7ee2a35b7970bc7/nodejs/node/issues/67397 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/47b0da639c2d4d71edfd1b421a099335817cb0284f95a70ce7ee2a35b7970bc7/nodejs/node/issues/67397 |
| og:image:alt | Version v28.0.0-pre Platform macos 26.6.2, arm64 (darwin 25.6.0) Subsystem net What steps will reproduce the bug? save this as repro.cjs and run with: ./node --js-immutable-arraybuffer repro.cjs co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fatihguzeldev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9e10bb0ecc0bd0f8692aa89586ee9b54e498d7ab9f244a44cdb5b93653a125ce |
| 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 | 32e57d5cc2ce6ce92ec6dceb65858344750c27c2 |
| 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