René's URL Explorer Experiment


Title: ffi: accept safe integer numbers for int64 and uint64 arguments · Issue #66198 · nodejs/node · GitHub

Open Graph Title: ffi: accept safe integer numbers for int64 and uint64 arguments · Issue #66198 · nodejs/node

X Title: ffi: accept safe integer numbers for int64 and uint64 arguments · Issue #66198 · nodejs/node

Description: What is the problem this feature will solve? Currently, int64 and uint64 FFI arguments require JavaScript bigint values. Passing a number is rejected even when it is a small integer that can be represented exactly by both JavaScript and ...

Open Graph Description: What is the problem this feature will solve? Currently, int64 and uint64 FFI arguments require JavaScript bigint values. Passing a number is rejected even when it is a small integer that can be rep...

X Description: What is the problem this feature will solve? Currently, int64 and uint64 FFI arguments require JavaScript bigint values. Passing a number is rejected even when it is a small integer that can be rep...

Opengraph URL: https://github.com/nodejs/node/issues/66198

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ffi: accept safe integer numbers for int64 and uint64 arguments","articleBody":"### What is the problem this feature will solve?\n\nCurrently, `int64` and `uint64` FFI arguments require JavaScript bigint values. Passing a number is rejected even when it is a small integer that can be represented exactly by both JavaScript and the native type.\n\nThis adds an explicit conversion at the call site when the value is already available as a number. A common example is passing a buffer and its length to a native function:\n\n```c\nuint64_t sum_buffer(const uint8_t* buffer, uint64_t length);\n```\n\n```js\nconst { functions } = ffi.dlopen(libraryPath, {\n  sum_buffer: {\n    arguments: ['buffer', 'u64'],\n    return: 'u64',\n  },\n});\n\nconst bytes = new Uint8Array([1, 2, 3]);\n\nfunctions.sum_buffer(bytes, bytes.byteLength);         // ERR_INVALID_ARG_VALUE\nfunctions.sum_buffer(bytes, BigInt(bytes.byteLength)); // 6n\n```\n\n`bytes.byteLength` is 3, but the caller still needs to wrap it in `BigInt()` because the native parameter is declared as `uint64_t`.\n\nThe same issue applies to arguments unrelated to buffers, such as counters or offsets:\n\n```js\nconst { functions } = ffi.dlopen(libraryPath, {\n  set_counter: {\n    arguments: ['u64'],\n    return: 'void',\n  },\n});\n\nconst count = 100;\nfunctions.set_counter(count); // ERR_INVALID_ARG_VALUE\nfunctions.set_counter(BigInt(count)); // 100\n```\n\nRequiring bigint makes sense when a value is outside JavaScript's safe integer range. For values already within that range, however, it seems useful to let the runtime validate and convert them rather than requiring callers to do so explicitly.\n\n### What is the feature you are proposing to solve the problem?\n\nAllow safe integer numbers as `int64` and `uint64` FFI arguments, alongside the existing bigint support.\n\nThe accepted number ranges would be:\n\n- int64 / i64: `Number.MIN_SAFE_INTEGER` through `Number.MAX_SAFE_INTEGER`.\n- uint64 / u64: 0 through `Number.MAX_SAFE_INTEGER`.\n\nNode.js would validate the number before converting it internally. Fractional numbers, `NaN`, infinities, and numbers outside the accepted range would throw `ERR_INVALID_ARG_VALUE`. Negative numbers would also be rejected for `uint64`.\n\n```js\nfunctions.sum_buffer(bytes, bytes.byteLength);\nfunctions.set_counter(100);\n```\nExisting bigint arguments would continue to work, including values beyond the safe integer range that fit within the declared native type:\n\n```js\nfunctions.set_counter(100);                         // Accepted\nfunctions.set_counter(100n);                        // Still accepted\nfunctions.set_counter((2n ** 64n) - 1n);             // Still accepted\n\nfunctions.set_counter(-1);                          // Rejected\nfunctions.set_counter(1.5);                         // Rejected\nfunctions.set_counter(Number.MAX_SAFE_INTEGER + 1); // Rejected\nfunctions.set_counter(2n ** 64n);                    // Rejected\n```\n\nThe number restriction is intentional: converting an unsafe number to bigint cannot recover precision that may already have been lost. Callers would still need bigint for integers outside the safe integer range.\n\nThis proposal only changes which values are accepted as native function arguments. It does not change 64-bit return values, which would remain bigint, or infer a buffer length automatically.\n\nI've opened a related PR #66197  with the implementation, documentation, and tests covering the Fast API, SharedBuffer, and generic argument conversion paths. A review of the proposed behavior and implementation would be appreciated.\n\n### What alternatives have you considered?\n\nI haven't identified another approach that addresses this without changing the accepted argument types. Callers can continue using `BigInt()` explicitly, or put those conversions in their own wrapper functions.\n\nBoth approaches work, but callers still need to handle the conversion whenever an existing number is passed to an `int64` or `uint64` parameter. For example, passing `buffer.byteLength` requires an extra `BigInt()` call even though the length is already a suitable integer.\n\nAccepting safe integer numbers would remove that extra step for common calls while retaining explicit range checks and bigint support for larger values.","author":{"url":"https://github.com/HoonDongKang","@type":"Person","name":"HoonDongKang"},"datePublished":"2026-09-22T09:20:37Z","url":"https://github.com/nodejs/node/issues/66198"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:41a02cae-702c-7f69-fd73-0634b0d5e14f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC380:34E7AF:69818E:89E7C8:6AED2F7C
html-safe-nonce1d64496ebaaf4379444ebc3f02409a70a9cbc1f2a576dd43df5379ea406090a5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzgwOjM0RTdBRjo2OTgxOEU6ODlFN0M4OjZBRUQyRjdDIiwidmlzaXRvcl9pZCI6IjYzMjA2MzE1MTYwMzI2NTQwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac365ba156e30250c232b5fae08377a095fadd70582555781af05403b74866d1fd
hovercard-subject-tagissue:5537617998
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/66198/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4faa2e88df9a9c1973bf591ee1d4b5d00bad0ec00e0b114097c9ed93de9c4779/nodejs/node/issues/66198
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4faa2e88df9a9c1973bf591ee1d4b5d00bad0ec00e0b114097c9ed93de9c4779/nodejs/node/issues/66198
og:image:altWhat is the problem this feature will solve? Currently, int64 and uint64 FFI arguments require JavaScript bigint values. Passing a number is rejected even when it is a small integer that can be rep...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameHoonDongKang
hostnamegithub.com
expected-hostnamegithub.com
Nonee51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release59ebb7b901cc154ecc179a44f266fcf69f343b30
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66198#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66198
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66198
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/66198
Reloadhttps://github.com/nodejs/node/issues/66198
Reloadhttps://github.com/nodejs/node/issues/66198
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66198
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66198
#66197https://github.com/nodejs/node/pull/66197
ffi: accept safe integer numbers for int64 and uint64 argumentshttps://github.com/nodejs/node/issues/66198#top
#66197https://github.com/nodejs/node/pull/66197
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
ffiIssues and PRs related to experimental Foreign Function Interface support.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22ffi%22
https://github.com/HoonDongKang
HoonDongKanghttps://github.com/HoonDongKang
on Sep 22, 2026https://github.com/nodejs/node/issues/66198#issue-5537617998
#66197https://github.com/nodejs/node/pull/66197
HoonDongKanghttps://github.com/HoonDongKang
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
on Sep 22, 2026https://github.com/nodejs/node/issues/66198#event-31588286373
github-project-automationhttps://github.com/apps/github-project-automation
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Sep 22, 2026https://github.com/nodejs/node/issues/66198#event-31588301394
github-project-automationhttps://github.com/apps/github-project-automation
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
on Sep 22, 2026https://github.com/nodejs/node/issues/66198
trivikrhttps://github.com/trivikr
ffiIssues and PRs related to experimental Foreign Function Interface support.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22ffi%22
on Sep 27, 2026https://github.com/nodejs/node/issues/66198#event-31942242924
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#66197https://github.com/nodejs/node/pull/66197
on Oct 3, 2026https://github.com/nodejs/node/issues/66198#event-32390863903
efekrsklhttps://github.com/efekrskl
on Oct 3, 2026https://github.com/nodejs/node/issues/66198#event-32391510065
ffi: accept safe integer numbers for 64-bit argumentshttps://github.com/efekrskl/node/commit/617e082ff20a486031df2ca117bb5f1cb226df32
617e082https://github.com/efekrskl/node/commit/617e082ff20a486031df2ca117bb5f1cb226df32
aduh95https://github.com/aduh95
on Oct 3, 2026https://github.com/nodejs/node/issues/66198#event-32398861338
ffi: accept safe integer numbers for 64-bit argumentshttps://github.com/nodejs/node/commit/84672a3db9d1a56284b54213817684b16cfac13d
84672a3https://github.com/nodejs/node/commit/84672a3db9d1a56284b54213817684b16cfac13d
ffi: accept safe integer numbers for 64-bit argumentshttps://github.com/nodejs/node/commit/021f7d8d98a8acce6b7f5580ed11319f69a41c47
021f7d8https://github.com/nodejs/node/commit/021f7d8d98a8acce6b7f5580ed11319f69a41c47
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66198
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66198
feature requestIssues requesting new Node.js features.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
ffiIssues and PRs related to experimental Foreign Function Interface support.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22ffi%22
Node.js feature requestshttps://github.com/orgs/nodejs/projects/4
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.