ffi: add getCurrentEventLoop.#64323
Open
ShogunPanda wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
Signed-off-by: Paolo Insogna <paolo@cowtech.it> Assisted-By: OpenAI:GPT-5.5 <openai/gpt-5.5>
ac99814 to
260f152
Compare
Collaborator
jasnell
reviewed
Jul 7, 2026
| This is unsafe and dangerous. The returned pointer is only valid for the lifetime | ||
| of the current environment. Using it after the environment exits, or from native | ||
| code that assumes a different thread or lifetime, can crash the process or | ||
| corrupt memory. |
Member
There was a problem hiding this comment.
Heh, I love this comment. "Here you go! Have fun cutting yourself!" 😆
Is there someway we could make this safer by returning an opaque value that becomes invalid when the environment exits or if it is used from the wrong thread?
Contributor
Author
There was a problem hiding this comment.
Lol. Thanks!
Unfortunately not. In FFI I'm avoiding abstractions to eventually get to a real value. The pointer is a raw memory address, with all its danger, a-la C style :)
jasnell
approved these changes
Jul 7, 2026
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.
This add getCurrentEventLoop to node:ffi.
Together with the
dlopen(null, ...)to interact with the current worker/main thread event loop.Assisted-By: OpenAI:GPT-5.5 <openai/gpt-5.5>