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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process: port on-exit-leak-free to core #53239
process: port on-exit-leak-free to core #53239
Changes from all commits
fb74bb6
bd3e04c
4cc7d31
2889b9f
f2b8e64
f7ff57a
999687e
ce99d95
8dd7e80
cafc2ab
f155afc
dccd8c1
c6978a0
5842163
c3bb74a
2f887dc
893c79f
5aab8fb
c094345
8002996
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it guaranteed that V8 will always run the garbage collector before the process exits? It'd seem simpler not to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there's no guarantee when the GC will run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description here doesn’t seem very accurate. All closures can reference the context. The special thing about arrow function is that it captures the
this
binding so it can leak thethis
object in the closest non-arrow closure context if the arrow function closure is kept alive by a global registry.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some changes requested by Matteo, I thought it would be a good idea to document exactly how the user should use the feature and what they could do to accidentally hold the reference to the object.
What about:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible for the callback to get called twice if the object is still alive after the first callback invocation so it needs to consider re-entrancy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like
object.isDisposed
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callRefsToFree
is called synchronously, so I don't think this function can be called twice since we have one instance per process.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't get to control when the finalization registry tasks are posted, and it can happen after we emit the process exit event to JS land
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you think it is worth, we can address it in a follow-up PR