In this setup the complete callback is not called with the AsyncResource as target and this results in setting the wrong object as current resource in MakeCallback.
Calling callbacks with undefined/null/global as target is not that uncommon.
The before/after callbacks are called with the correct asyncId but AsyncLocalStore relies on the current resource.
Version
18.1.0, 14.19.1 (and most likely a lot others)
Platform
Tested on
Microsoft Windows NT 10.0.22000.0 x64
but very likely platform independent.Subsystem
async_hooks
What steps will reproduce the bug?
Use
node::MakeCallback()
with a receiver different to theAsyncResource
.See e.g. snappy 6.x which uses
Nan::AsyncWorker
.In this setup the complete callback is not called with the
AsyncResource
as target and this results in setting the wrong object as current resource inMakeCallback
.Calling callbacks with undefined/null/global as target is not that uncommon.
The before/after callbacks are called with the correct asyncId but
AsyncLocalStore
relies on the current resource.How often does it reproduce? Is there a required condition?
Always if
MakeCallback
is used with a receiver different then theAsyncResource
object.What is the expected behavior?
no context loss
What do you see instead?
context loss
Additional information
No response