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

Commit 068260c

Browse files
authored
fix: allow non-objects for plugins to disable automatic tracing (#720)
PR-URL: #720
1 parent eafaa45 commit 068260c

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ function initConfig(projectConfig: Forceable<Config>):
8989
// 4. Default Config (as specified in './config')
9090
const config = extend(
9191
true, {[FORCE_NEW]: projectConfig[FORCE_NEW]}, defaultConfig,
92-
envSetConfig, projectConfig, envConfig);
92+
envSetConfig, projectConfig, envConfig, {plugins: {}});
93+
// The empty plugins object guarantees that plugins is a plain object,
94+
// even if it's explicitly specified in the config to be a non-object.
9395

9496
// Enforce the upper limit for the label value size.
9597
if (config.maximumLabelValueSize >

test/plugins/test-trace-http2.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,15 @@ describe('test-trace-http2', () => {
244244
assert.equal(
245245
span.labels[TraceLabels.ERROR_DETAILS_NAME],
246246
'Error [ERR_HTTP2_STREAM_ERROR]');
247-
assert.equal(
248-
span.labels[TraceLabels.ERROR_DETAILS_MESSAGE],
249-
'Stream closed with error code 2');
247+
if (semver.satisfies(process.version, '>=9.11')) {
248+
assert.equal(
249+
span.labels[TraceLabels.ERROR_DETAILS_MESSAGE],
250+
'Stream closed with error code NGHTTP2_INTERNAL_ERROR');
251+
} else {
252+
assert.equal(
253+
span.labels[TraceLabels.ERROR_DETAILS_MESSAGE],
254+
'Stream closed with error code 2');
255+
}
250256
session.destroy();
251257
server.close();
252258
done();

test/test-config-plugins.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ describe('Configuration: Plugins', () => {
6565
e => assert.ok(plugins![e].includes(`plugin-${e}.js`)));
6666
});
6767

68+
it('should handle non-object', () => {
69+
trace.start({plugins: false as {}});
70+
assert.deepStrictEqual(plugins, {});
71+
});
72+
6873
it('should overwrite builtin plugins correctly', () => {
6974
trace.start({plugins: {express: 'foo'}});
7075
assert.ok(plugins);

0 commit comments

Comments
 (0)