-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Use of WeakRef for resource #84
Comments
The documentation states the following about storing a resource in a
I am not quite sure if this would prevent us from using a If you have a reproducible case could you share it here? Preferably a small code example that does not rely on external dependencies that we could use for testing. |
Looks like MDN also explicitly states that a |
This seems promising though:
Let's give this a try. |
Closes mafintosh#84 Signed-off-by: Jon Koops <jonkoops@gmail.com>
@jonkoops I've tested the change and it haven't solved an issue. But then I've realized, that when I was experimenting with this change myself, I also removed stack-trace capturing code and it turned out to be the culprit as well. So hard reference was stored in map directly in resource field, as well as in stack trace frames. Can't be sure that every stack trace will expose such problems, but in attached sample app it is. I've created commit that changes stack trace capturing code and stores only line number + filename: betalb@5b6c964 And the sample-app.tar.gz, it can be launched with Version of node that I was using |
How very strange, I would not expect this API to be this leaky, that almost sound like a bug in Node.js itself to me. To be fair, the I'd be amicable to include your proposed fix in the meantime, as we don't really need to hold on to the actual resource itself. Would you be willing to submit a PR so it can be attributed to you @betalb? |
Sure, I can do this, but after 6th of Jan |
Sure, no rush. Let me know if you cannot and I will take care of it 👍 |
Closes #84 Co-authored-by: Jon Koops <jonkoops@gmail.com>
Is it possible to use WeakRef for storing reference to resource?
I've observed one issue with undici library that relies on FinalizationRegistry to call destroy of async resource, but why-is-node-running is keeping strong reference to resource, preventing it from being garbage collected and destroyed.
The text was updated successfully, but these errors were encountered: