Skip to content

Commit 85b75d1

Browse files
Fix crash when http/https libraries use getters (#434)
fixes #433 This works around an issue when using esbuild to bundle (e.g. using aws-lambda-nodejs) The fix is adapted from: follow-redirects/follow-redirects#146
1 parent 1894179 commit 85b75d1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/core/lib/patchers/http_p.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,19 @@ function enableCapture(module, downstreamXRayEnabled, subsegmentCallback) {
196196
}
197197

198198
module.__request = module.request;
199-
module.request = function captureHTTPsRequest(...args) {
199+
function captureHTTPsRequest(...args) {
200200
return captureOutgoingHTTPs(module.__request, ...args);
201-
};
201+
}
202202

203203
module.__get = module.get;
204-
module.get = function captureHTTPsGet(...args) {
204+
function captureHTTPsGet(...args) {
205205
return captureOutgoingHTTPs(module.__get, ...args);
206-
};
206+
}
207+
208+
Object.defineProperties(module, {
209+
request: { value: captureHTTPsRequest, configurable: true, enumerable: true, writable: true },
210+
get: { value: captureHTTPsGet, configurable: true, enumerable: true, writable: true },
211+
});
207212
}
208213

209214
module.exports.captureHTTPsGlobal = captureHTTPsGlobal;

0 commit comments

Comments
 (0)