node-fibers icon indicating copy to clipboard operation
node-fibers copied to clipboard

Restore an *actual* async resource, not just the ID

Open znewsham opened this issue 3 years ago • 1 comments

I know the project is dying, feel free to ignore this PR (I need it for my work on AsyncResources and it seems generally relevant)

The existing save/restore stack looses the reference to the actual AsyncResource - if you try to use (for example) AsyncLocalStorage - it will fail because the current asyncResource is undefined (even though the ID is).

This PR adds one more gnarly hack to these functions - to grab the existing AsyncResource then manually push it back onto the stack.

I modified the async_hooks test to check for this too. All the tests that were passing before are passing now (for some reason pool and cleanup fail for me on master).

znewsham avatar Nov 04 '22 20:11 znewsham

I love gnarly hacks. This change definitely looks more promising than the other PR. I'm not cutting more releases at this time but I'll make sure to take a note of the change in case anyone else runs into the same issues. Thank you for the contribution.

laverdet avatar Nov 11 '22 19:11 laverdet