Open sandstar opened 9 years ago
I have the same issue when using java bridge for node (node-java).
Disabling the useCleanCache
puts away the error Error: Module did not self-register
but I wonder what is the effect on doing this and if there's a way to fix it without altering the setting?
Disabling useCleanCache
also remove the Error: Module did not self-register
for gcloud
.
My guess is that native modules can only be loaded once. When mockery clears the cache, node tries to load the native module a second time since it's not in cache. However, the native module doesn't "self-register" a second time because it knows it's already been loaded once.
To fix this, mockery can cache ".node" modules in node's original cache even when useCleanCache
is enabled. That way, they never need to be loaded multiple times.
This fix would be a problem if ".node" modules required other modules, but I'm pretty sure that doesn't happen.
Hi there,
Any chance you'll fix this in mockery ?
Thx
Mockery's restoration of the cache on disable() seems inadequate for addon modules.
I'm using Windows 7, SP2, 64bit, node 0.12.4 (32 bit) and Mockery 1.4.0.
Clone node-addon-examples and add a couple of javascript files to the root folder of the first example:
node-addon-examples\1_hello_world\node_0.12
.File 1: tock.js (12 lines)
File 2: tick.js (1 line)
In a command window, cd to the root folder and run the following commands.
The output was the following.
If we alter the code to turn off
useCleanCache
or if we uncomment the line toregisterSubstitute()
and rerun, then it runs without error.I tried a similar test on other examples in this repo of addon examples, with similar results.