-
Notifications
You must be signed in to change notification settings - Fork 297
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
Behavior of loading request module is undesirable #89
Comments
Thanks for bringing that up @rustyconover ! Until either node fixes the referenced issue or the new |
I found out that this issue is not relevant in practice because
Here is the test code that verifies that: var k = require('kerberos');
var request = require('request');
var rp = require('request-promise'); // ==> Success - verifies point 1
var k2 = require('kerberos'); // ==> Success - verifies point 2
// Clear the cache like Request-Promise does but without restoring it!
var _ = require('lodash');
_.forEach(_.keys(require.cache), function (key) {
delete require.cache[key];
});
var k3 = require('kerberos'); // ==> Error: Module did not self-register. - ensures the test would fail Nonetheless, thanks for bringing this up @rustyconover ! I was not aware of that and it could very well have been an issue or may even become one in the future. I will keep an eye on that! |
The code to load the request module freshly causes undesirable effects when the request module loads a shared library. Lets review some code from
lib/rp.js
:This code clears the the
require.cache
so that the request module can be loaded freshly, but if request.js loads a shared library based module withprocess.dlopen
(for instance the kerberos module) that shared library (the c/c++ part) remains in memory, but as far as node.js is concerned it hasn't been loaded. So the second time that node.js attempts to load the module, it throws an error, because the dynamic loader can't load the same symbols twice.Here is the error:
Node issue: nodejs/node#5016 may be relevant.
Please consider an alternative behavior that is less error prone or one that is more friendly to modules that include a shared library component.
The text was updated successfully, but these errors were encountered: