Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit a3ea16d

Browse files
authored
fix: fix https tracing breakage in node <9 and rewrite http tests (#717)
PR-URL: #717
1 parent c66b041 commit a3ea16d

5 files changed

Lines changed: 397 additions & 343 deletions

File tree

src/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ export const defaultConfig = {
179179
'hapi': path.join(pluginDirectory, 'plugin-hapi.js'),
180180
'http': path.join(pluginDirectory, 'plugin-http.js'),
181181
'http2': path.join(pluginDirectory, 'plugin-http2.js'),
182-
'https': path.join(pluginDirectory, 'plugin-https.js'),
183182
'knex': path.join(pluginDirectory, 'plugin-knex.js'),
184183
'koa': path.join(pluginDirectory, 'plugin-koa.js'),
185184
'mongodb-core': path.join(pluginDirectory, 'plugin-mongodb-core.js'),

src/plugins/plugin-http.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ function patchHttp(http: HttpModule, api: TraceAgent) {
183183
}
184184
}
185185

186-
// https.get depends on https.request in <8.9 and >=8.9.1
186+
// https.get depends on Node http internals in 8.9.0 and 9+ instead of the
187+
// public http module.
187188
function patchHttps(https: HttpsModule, api: TraceAgent) {
188189
shimmer.wrap(https, 'request', (request) => {
189190
return makeRequestTrace('https:', request, api);
@@ -215,6 +216,13 @@ const plugin: Plugin = [
215216
patch: patchHttp,
216217
unpatch: unpatchHttp,
217218
},
219+
{
220+
file: 'https',
221+
versions: '<8.9.0 || ^8.9.1',
222+
// require http if it wasn't patched yet, because the https client uses
223+
// the public 'http' module.
224+
patch: () => require('http')
225+
},
218226
{
219227
file: 'https',
220228
versions: '=8.9.0 || >=9.0.0',

src/plugins/plugin-https.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)