ffi: support Symbol.dispose on DynamicLibrary#62925
Open
mcollina wants to merge 2 commits intonodejs:mainfrom
Open
ffi: support Symbol.dispose on DynamicLibrary#62925mcollina wants to merge 2 commits intonodejs:mainfrom
mcollina wants to merge 2 commits intonodejs:mainfrom
Conversation
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.
Collaborator
|
Review requested:
|
bengl
reviewed
Apr 24, 2026
| toArrayBuffer, | ||
| } = internalBinding('ffi'); | ||
|
|
||
| ObjectDefineProperty(DynamicLibrary.prototype, SymbolDispose, { |
Member
There was a problem hiding this comment.
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).
bengl
approved these changes
Apr 24, 2026
ShogunPanda
approved these changes
Apr 24, 2026
addaleax
approved these changes
Apr 24, 2026
Collaborator
Member
Author
|
Commit not validating due to nodejs/core-validate-commit#146 |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Install
Symbol.disposeonDynamicLibrary.prototype(callingclose()) and on the object returned fromffi.dlopen(), so both can be used with theusingdeclaration for automatic cleanup.