Title: vfs: MemoryProvider.setReadOnly() does not prevent writes through existing file descriptors · Issue #64401 · nodejs/node · GitHub
Open Graph Title: vfs: MemoryProvider.setReadOnly() does not prevent writes through existing file descriptors · Issue #64401 · nodejs/node
X Title: vfs: MemoryProvider.setReadOnly() does not prevent writes through existing file descriptors · Issue #64401 · nodejs/node
Description: Version latest main branch Platform 7.1.2-arch3-1 Subsystem vfs What steps will reproduce the bug? const vfs = require('node:vfs'); const provider = new vfs.MemoryProvider(); const virtualFs = vfs.create(provider, { emitExperimentalWarni...
Open Graph Description: Version latest main branch Platform 7.1.2-arch3-1 Subsystem vfs What steps will reproduce the bug? const vfs = require('node:vfs'); const provider = new vfs.MemoryProvider(); const virtualFs = vfs....
X Description: Version latest main branch Platform 7.1.2-arch3-1 Subsystem vfs What steps will reproduce the bug? const vfs = require('node:vfs'); const provider = new vfs.MemoryProvider(); const virtualF...
Opengraph URL: https://github.com/nodejs/node/issues/64401
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"vfs: MemoryProvider.setReadOnly() does not prevent writes through existing file descriptors","articleBody":"### Version\n\nlatest main branch\n\n### Platform\n\n```text\n7.1.2-arch3-1\n```\n\n### Subsystem\n\nvfs\n\n### What steps will reproduce the bug?\n\n ```js\nconst vfs = require('node:vfs');\n\n const provider = new vfs.MemoryProvider();\n const virtualFs = vfs.create(provider, {\n emitExperimentalWarning: false,\n });\n\n virtualFs.writeFileSync('/file.txt', 'old');\n\n const fd = virtualFs.openSync('/file.txt', 'r+');\n\n provider.setReadOnly();\n\n const data = Buffer.from('new');\n virtualFs.writeSync(fd, data, 0, data.length, 0);\n\n console.log(virtualFs.readFileSync('/file.txt', 'utf8')); // \"new\"\n\n virtualFs.closeSync(fd);\n\n```\n Run with:\n\n` node --experimental-vfs reproduction.js`\n\n### How often does it reproduce? Is there a required condition?\n\nIt reproduces consistently.\n\nThe writable file descriptor must be opened before setReadOnly() is called. Opening a new writable descriptor after setReadOnly() correctly throws EROFS.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nOnce setReadOnly() has been called, subsequent writes through any VirtualFileSystem backed by that provider should throw an error with code === 'EROFS', including writes through file descriptors that were opened before the provider became read-only.\n\nThis follows the current documentation for MemoryProvider.setReadOnly():\n\n > Subsequent writes through any VirtualFileSystem using this provider throw EROFS.\n\nftruncateSync() through an existing writable descriptor should similarly throw EROFS.\n\n### What do you see instead?\n\nwriteSync() succeeds and modifies the file even though:\n\n`virtualFs.readonly === true`\n\nftruncateSync() also succeeds through a descriptor opened before setReadOnly().\n\n### Additional information\n\nMemoryProvider.openSync() checks provider.readonly when a writable handle is opened. However, an existing MemoryFileHandle does not retain or re-check the provider's read-only state.\n\nFile-descriptor operations such as VirtualFileSystem.writeSync() and ftruncateSync() operate directly on the stored handle, so they bypass the provider's current readonly value.\n\nPath-based writes made after setReadOnly(), such as writeFileSync(), already throw EROFS as expected.","author":{"url":"https://github.com/Archkon","@type":"Person","name":"Archkon"},"datePublished":"2026-07-10T02:56:47Z","url":"https://github.com/nodejs/node/issues/64401"}
| 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:cb1b7337-bb06-fdaf-6b02-c44cd3b54715 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D3FE:14E440:1021EF:148F9F:6B033850 |
| html-safe-nonce | 7db595ce466de1201875c1f141c1b328a70697db6728763a3efeac8e6cea4df9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0ZFOjE0RTQ0MDoxMDIxRUY6MTQ4RjlGOjZCMDMzODUwIiwidmlzaXRvcl9pZCI6IjMyMDc1NDE4NTgzMTQxNzI0OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 85554481b9e2d999a96138895c3e0e3953a5217c4f7fc675b36c52e7b5391e55 |
| hovercard-subject-tag | issue:4851598062 |
| 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/64401/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afaab26a70fa5273c019b1660d9bc94d98014144fa9dd83c61d02fb95ed685ec/nodejs/node/issues/64401 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afaab26a70fa5273c019b1660d9bc94d98014144fa9dd83c61d02fb95ed685ec/nodejs/node/issues/64401 |
| og:image:alt | Version latest main branch Platform 7.1.2-arch3-1 Subsystem vfs What steps will reproduce the bug? const vfs = require('node:vfs'); const provider = new vfs.MemoryProvider(); const virtualFs = vfs.... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Archkon |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| 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