Nan's NanCallback::Call goes through Node's MakeCallback, which is designed to be used only by event callbacks (i.e. functions called from the libuv event loop), not invoked synchronously from a call stack where JS code was already running. This is because when MakeCallback returns it assumes it's the end of the current "tick", so it calls not only the callback you told it to, but also all tick callbacks registered for the current tick. Since node-weak's TargetCallback is invoked from GC, which could be invoked from anywhere at any time, the code it calls into (the callback attached to each weakref object) needs to be designed and written carefully, essentially to the standards of signal or interrupt handlers, since they preempt any JS code that was already running when GC kicked in. This is fine as long as the weakref callbacks are written to this standard, but it also means TargetCallback needs to avoid accidentally calling other callbacks that weren't written to this standard. The fix is to call the callback directly, instead of via MakeCallback. Fixes #35.
The memory management of the `data` structure is now handled internally by nan.
Squashed commit of the following: commit e1e4257 Author: duralog <firstname.lastname@example.org> Date: Thu May 8 19:56:11 2014 +0200 support 0.8.x and 0.10.x and wait for nan-1.1.0 commit 944999e Author: flames of love <email@example.com> Date: Thu May 8 19:34:42 2014 +0200 update for latest nan changes commit 3b06292 Author: flames of love <firstname.lastname@example.org> Date: Tue May 6 17:05:03 2014 +0200 remove GetPersistent .. not used commit f2303c1 Author: flames of love <email@example.com> Date: Tue May 6 16:45:34 2014 +0200 update for node v0.11.13 Closes #27.
And the callback invoking logic has been moved to JS-land. NanCallback is also now in use.
With a macro
Fixes seg fault in test-weakref.js test case.