You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
that's a good point. I remember we discussed it with @Qard , @puzpuzpuz and @Flarna on the PR but I can't find it back. There might actually be a memory leak in case of a reused resource.
I need to circle back in the discussions but this is a massive one and Github has a hard time with it(#26540).
All existing resource reuse should be using an AsyncResource for each reuse, so that should no longer be true. It would be a bug if anything doesn't use AsyncResource when reusing a resource now.
The line in the doc is not exactly true anymore, though I hesitate slightly to remove it as it's still possible for native modules to reuse a resource without an AsyncResource and there's not really anything we can do to stop them. I lean on the side of continuing to discourage people from relying on that capability.
Reacted by Vladimir de Turckheim and Andrei Pechkurov
There should be no reuse anymore within node core - at least not in the sense of the resource visible via async hooks. HTTPParser objects are still reused and also the Socket in HTTP agent. But on every reuse a new "wrapper object" passed to AsyncHooks is created (even it's not of type AsyncResource).
@FranckFreiburger
As the question seems to be answered, is it ok to close the issue? Please feel free to submit a PR that would add more context to the doc.
Activity
vdeturckheim commentedon May 27, 2020
Hello @FranckFreiburger !
that's a good point. I remember we discussed it with @Qard , @puzpuzpuz and @Flarna on the PR but I can't find it back. There might actually be a memory leak in case of a reused resource.
I need to circle back in the discussions but this is a massive one and Github has a hard time with it(#26540).
Qard commentedon May 27, 2020
All existing resource reuse should be using an
AsyncResourcefor each reuse, so that should no longer be true. It would be a bug if anything doesn't useAsyncResourcewhen reusing a resource now.The line in the doc is not exactly true anymore, though I hesitate slightly to remove it as it's still possible for native modules to reuse a resource without an
AsyncResourceand there's not really anything we can do to stop them. I lean on the side of continuing to discourage people from relying on that capability.Flarna commentedon May 28, 2020
There should be no reuse anymore within node core - at least not in the sense of the resource visible via async hooks.
HTTPParserobjects are still reused and also theSocketin HTTP agent. But on every reuse a new "wrapper object" passed to AsyncHooks is created (even it's not of typeAsyncResource).see e.g
node/lib/_http_agent.js
Line 235 in 5d81e4d
But there is no way to gurantee that some userland module reuses an resource object. And this potential reuse can be native or managed.
There is an open PR regarding potential wrong reuse via NAPI: #32930 But again it dependes on the actual native addon.
puzpuzpuz commentedon Jun 4, 2020
@FranckFreiburger
As the question seems to be answered, is it ok to close the issue? Please feel free to submit a PR that would add more context to the doc.