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

async_hooks in node 8 #739

Open
kkoopa opened this issue Feb 22, 2018 · 5 comments
Open

async_hooks in node 8 #739

kkoopa opened this issue Feb 22, 2018 · 5 comments

Comments

@kkoopa
Copy link
Collaborator

kkoopa commented Feb 22, 2018

There were major changes to async_hooks between 8.5.0 and 8.6.0.
The same setup that works on 8.6.0 and above results in the following assertion on 8.5.0:
../src/node.cc:1379:v8::MaybeLocal<v8::Value> node::MakeCallback(node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context): Assertion '(env->current_async_id()) == (asyncContext.async_id)' failed.

Until this is resolved, async_hooks will remain disabled for all of Node 8. See #738.

@kkoopa kkoopa changed the title async_hooks in node 8 older than 8.6.0 async_hooks in node 8 Feb 22, 2018
@bnoordhuis
Copy link
Member

cc @ofrobots

@kkoopa
Copy link
Collaborator Author

kkoopa commented Feb 25, 2018

After closer inspection, it seems the problem stems from env->current_async_id() always returning 0.

@ofrobots
Copy link
Contributor

Thanks for the ping @bnoordhuis. I have sporadic time availability due to travel presently – I will take a look when possible.

@Flarna
Copy link
Member

Flarna commented Feb 26, 2018

Not sure if this is the root cause of the above assert but in nodejs/node#14040 there was a significant change in async hooks API but it was not applied on 8.6.0 (already before)
e.g. node::EmitAsyncInit() requires 4 parameters in Node 8.0.0 but only 3 mandatory in latest 8.x. Also return type differs.

Above PR introduced also a backward compatible APIs. Maybe using this for 8.x allows to introduce async_hooks in NAN already for 8.x and still allow reuse of binaries for all 8.x versions.

@kkoopa
Copy link
Collaborator Author

kkoopa commented Feb 26, 2018

Not sure if this is the root cause of the above assert but in nodejs/node#14040 there was a significant change in async hooks API but it was not applied on 8.6.0 (already before)
e.g. node::EmitAsyncInit() requires 4 parameters in Node 8.0.0 but only 3 mandatory in latest 8.x. Also return type differs.

Yes, that partly applies to Node 8.0.0, but is rather easily worked around. I have code which compiles with 8.0.0, but still does not have an execution scope set up and leads to the assert triggering.

It seems (almost) all minor versions between 8.0 and 8.5 will need testing and some shimming and conditional compilation to smooth out differences. The javascript API is also affected by changes and renaming, but is out of scope for NAN, apart from getting the tests running correctly.

Above PR introduced also a backward compatible APIs. Maybe using this for 8.x allows to introduce async_hooks in NAN already for 8.x and still allow reuse of binaries for all 8.x versions.

This seems interesting. I had not thought about using the legacy API in this way, but it might actually work. It might lead to some deprecation warnings, but then again those old versions of Node 8 should not be used anyway, so it could be worth paying that price.

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

No branches or pull requests

4 participants