Title: `fs.readSync` does not validate invalid `position` type (accepts object instead of throwing) · Issue #62638 · nodejs/node · GitHub
Open Graph Title: `fs.readSync` does not validate invalid `position` type (accepts object instead of throwing) · Issue #62638 · nodejs/node
X Title: `fs.readSync` does not validate invalid `position` type (accepts object instead of throwing) · Issue #62638 · nodejs/node
Description: Version v24.13.1 Platform Linux KContainer 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? Hi, I would like to report a behavior in Node that c...
Open Graph Description: Version v24.13.1 Platform Linux KContainer 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? Hi, I would ...
X Description: Version v24.13.1 Platform Linux KContainer 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? Hi, I would ...
Opengraph URL: https://github.com/nodejs/node/issues/62638
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`fs.readSync` does not validate invalid `position` type (accepts object instead of throwing)","articleBody":"### Version\n\nv24.13.1\n\n### Platform\n\n```text\nLinux KContainer 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 x86_64 x86_64 GNU/Linux\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nHi,\n\nI would like to report a behavior in Node that can be reproduced by running the below snippet\n```javascript\n\"use strict\"\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nconst memPath = fs.mkdtempSync(path.join(os.tmpdir(), 'node-temp-'));\nconst memFile = path.join(memPath, 'tempfile');\nfs.writeFileSync(memFile, '');\n\n// Open the file for reading and writing\nconst fd = fs.openSync(memFile, 'r+');\n\nconst ankor = new TextEncoder().encode('');\n\n// This call is intentionally incorrect: `position` should be a number or null.\ntry {\n fs.readSync(fd, ankor, 0, ankor.length, { not: 'a number' } /* invalid position */);\n console.log('fs.readSync did not throw as expected');\n} catch (err) {\n console.log('fs.readSync threw an error as expected:', err instanceof TypeError ? 'TypeError' : err.name, '-', err.message);\n}\n\nfs.closeSync(fd);\n```\n\n### How often does it reproduce? Is there a required condition?\n\nNo special condition for reproduction\n\n### What is the expected behavior? Why is that the expected behavior?\n\nPosition argument must be a number and error should be thrown\nAccording to the documentation it should be number: https://nodejs.org/api/fs.html#fsreadsyncfd-buffer-offset-length-position\n```\nroot@KContainer:~/14128# deno run -A poc.mjs\nfs.readSync threw an error as expected: TypeError - The \"position\" argument must be of type bigint or integer. Received an instance of Object\n```\n\n### What do you see instead?\n\nDoes not throw even in strict mode\n```\nroot@KContainer:~/14128# node poc.mjs\nfs.readSync did not throw as expected\n```\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/kevgeoleo","@type":"Person","name":"kevgeoleo"},"datePublished":"2026-04-08T13:13:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/62638/node/issues/62638"}
| 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:cd3c5edf-8dd0-6f68-f74b-f25e5bdc3134 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E48C:237528:2677692:3667BD2:6A4CEBA5 |
| html-safe-nonce | 0443b5d66809fd6c68d42c1fee34c563067a301b06c2d4274fe9885b1f4e0bec |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDhDOjIzNzUyODoyNjc3NjkyOjM2NjdCRDI6NkE0Q0VCQTUiLCJ2aXNpdG9yX2lkIjoiNjI0OTM2MjYyMDc0ODE5Njc3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 830f9779546585196b76bd918bebd427bc045e6232b0e47a65a5307576716173 |
| hovercard-subject-tag | issue:4224763303 |
| 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/62638/issue_layout |
| twitter:image | https://opengraph.githubassets.com/52b64695c54663d3d7c999226c970dba32e89d86add0ab33ad4bdccccd8a3bc0/nodejs/node/issues/62638 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/52b64695c54663d3d7c999226c970dba32e89d86add0ab33ad4bdccccd8a3bc0/nodejs/node/issues/62638 |
| og:image:alt | Version v24.13.1 Platform Linux KContainer 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 x86_64 x86_64 GNU/Linux Subsystem No response What steps will reproduce the bug? Hi, I would ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kevgeoleo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8 |
| 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 | c5a57f04eeb310f57c73fd6d751d957e2ca27ed2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width