Skip to content
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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

znewsham
Copy link

@znewsham znewsham commented Nov 4, 2022

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).

@@ -30,6 +30,7 @@ function setupAsyncHacks(Fiber) {
// Older (or newer?) versions of node may not support this API
try {
var aw = process.binding('async_wrap');
var ah = require('async_hooks');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason my editor hates tabs :(

@laverdet
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants