Skip to content

ffi: support Symbol.dispose on DynamicLibrary#62925

Open
mcollina wants to merge 2 commits intonodejs:mainfrom
mcollina:ffi-symbol-dispose
Open

ffi: support Symbol.dispose on DynamicLibrary#62925
mcollina wants to merge 2 commits intonodejs:mainfrom
mcollina:ffi-symbol-dispose

Conversation

@mcollina
Copy link
Copy Markdown
Member

@mcollina mcollina commented Apr 24, 2026

Install Symbol.dispose on DynamicLibrary.prototype (calling close()) and on the object returned from ffi.dlopen(), so both can be used with the using declaration for automatic cleanup.

Install [Symbol.dispose]() on DynamicLibrary.prototype (calling close())
and on the object returned from ffi.dlopen(), so both can be used with
the `using` declaration for automatic cleanup.
@mcollina mcollina requested review from ShogunPanda and cjihrig April 24, 2026 14:14
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/ffi

@nodejs-github-bot nodejs-github-bot added ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Apr 24, 2026
Comment thread lib/ffi.js Outdated
toArrayBuffer,
} = internalBinding('ffi');

ObjectDefineProperty(DynamicLibrary.prototype, SymbolDispose, {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just do a normal assignment here? That seems to be the norm in the rest of the codebase. (e.g. Timers, ChildProcess, Readline)

Use a direct prototype assignment for DynamicLibrary.prototype[Symbol.dispose],
matching the style used elsewhere in the codebase (e.g. Timers).
@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Apr 24, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 24, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@mcollina
Copy link
Copy Markdown
Member Author

Commit not validating due to nodejs/core-validate-commit#146

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.64%. Comparing base (a5b3d76) to head (6da4424).
⚠️ Report is 40 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62925      +/-   ##
==========================================
+ Coverage   89.61%   89.64%   +0.02%     
==========================================
  Files         706      706              
  Lines      219218   219228      +10     
  Branches    42002    42000       -2     
==========================================
+ Hits       196446   196516      +70     
+ Misses      14666    14624      -42     
+ Partials     8106     8088      -18     
Files with missing lines Coverage Δ
lib/ffi.js 96.69% <100.00%> (+0.12%) ⬆️

... and 46 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants