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

Why don't my asynchronous callbacks work? #12

Closed
kkoopa opened this issue Jul 27, 2013 · 7 comments
Closed

Why don't my asynchronous callbacks work? #12

kkoopa opened this issue Jul 27, 2013 · 7 comments

Comments

@kkoopa
Copy link
Collaborator

kkoopa commented Jul 27, 2013

Trying to adapt node-snappy for NAN, I cannot get the asynchronous callbacks to work. All asynchronous tests fail with 'Callback not called', where all synchronous tests pass. What am I doing wrong?

kkoopa/node-snappy@kesla:master...master

@rvagg
Copy link
Member

rvagg commented Jul 28, 2013

oh, cause we have a bug in NanCallback#GetFunction() I think. Assign the Function as:

v8::Local<v8::Object> obj = v8::Object::New();
obj->Set(NanSymbol("callback"), fn);
NanAssignPersistent(v8::Object, handle, obj); 

But fetch it as:

return NanPersistentToLocal(handle).As<v8::Function>();

But it should be, (as in Call()):

v8::Local<v8::Function> callback = NanPersistentToLocal(handle)->Get(NanSymbol("callback")).As<v8::Function>(); 

My bad. I can't recall why I added GetFunction() in and if I'm using it anywhere. It doesn't seem to be required in node-canvas.

@rvagg
Copy link
Member

rvagg commented Jul 28, 2013

fixed in current 0.2.0, try again.

@kkoopa
Copy link
Collaborator Author

kkoopa commented Jul 28, 2013

Hm, was I supposed to change anything other than NAN? Still not working after updating to new version.The end result is still the same, test reports 'callback not fired'.

I've had a successful build with 0.11.4 when not using NAN.

https://github.com/kkoopa/node-snappy

@rvagg
Copy link
Member

rvagg commented Jul 28, 2013

ok, try again with 0.2.0, it's the NanScope() in GetFunction(), moving the Local to a new scope lost the reference.

@rvagg
Copy link
Member

rvagg commented Jul 28, 2013

ooops, push didn't work, done now, working in your node-snappy.

@kkoopa
Copy link
Collaborator Author

kkoopa commented Jul 28, 2013

Works in 0.11, not in 0.10. But more tests do pass with 0.10 than previously.

@kkoopa
Copy link
Collaborator Author

kkoopa commented Jul 28, 2013

Never mind, removed a superfluous NanScope I had put locally in Init in binding.cc and now it seems to work. Upstream should pull it soon.
kesla/node-snappy#20

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

2 participants