-
Notifications
You must be signed in to change notification settings - Fork 121
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
Loading the latest version of box-node-sdk changes the Node HTTPS module in surprising and breaking ways #559
Comments
I tracked down the problem to the /**
* This currently needs to be applied to all Node.js versions
* in order to determine if the `req` is an HTTP or HTTPS request.
*
* There is currently no PR attempting to move this property upstream.
*/
const patchMarker = "__agent_base_https_request_patched__";
if (!https.request[patchMarker]) {
https.request = (function(request) {
return function(_options, cb) {
let options;
if (typeof _options === 'string') {
options = url.parse(_options);
} else {
options = Object.assign({}, _options);
}
if (null == options.port) {
options.port = 443;
}
options.secureEndpoint = true;
return request.call(https, options, cb);
};
})(https.request);
https.request[patchMarker] = true;
}
|
The problem in agent-base was fixed in TooTallNate/node-agent-base#36 and released in version 5.0.0, a year ago: https://github.com/TooTallNate/node-agent-base/releases/tag/5.0.0. The actual problem thus becomes that the dependencies of box-node-sdk are outdated. |
Updating |
#563 addresses this issue. Will a new version be released? |
The fix for this issue has been included in release |
Description of the Issue
I updated my box-node-sdk version from 1.33.0 to 1.35.0 and my codebase started exhibiting some strange behaviour when it comes to sending HTTP requests. After looking into it, I managed to isolate the issue to just
require ("box-node-sdk")
. The problem is that requiring this version of Box Node SDK causes the Node built-in http module to be monkey-patched in breaking ways. Based on the stack trace, I suspect #529 to be the culprit. See below.Steps to Reproduce
body.txt
:touch body.txt
;)node
Expected Behavior
The code is not affected by
require ('box-node-sdk')
, and proceeds to log "OK" again.Error Message, Including Stack Trace
I've also observed another error where the https interface was used in a different way which did not produce this type error, but instead caused all my requests to go to 127.0.0.1, even if the URL contained a different domain:
Versions Used
Node SDK: 1.35.0
The text was updated successfully, but these errors were encountered: