The only meaningful way to exactly match async hook callback with an async resource instance, e.g. a promise object, that I know of, is to use executionAsyncId() function in async resource’s code:

But then you would have to deal with Async Hooks API everywhere in your code, which kills the whole idea of single configuration point.

As a workaround, you may try to use resource argument of the destroy callback. For promises it will be a PromiseWrap object that has the promise property with the promise instance itself. See the doc:

Software engineer at Hazelcast. Node.js core collaborator. Architectural design and challenging problems are the things that I love in IT.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store