Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 21a8f5a

Browse files
authored
merge configs using a deep copy (#240)
We were losing the default values of some properties previously.
1 parent 75974f5 commit 21a8f5a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/agent/debuglet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Debuglet.prototype.normalizeConfig_ = function(config) {
155155
}
156156
};
157157

158-
config = extend({}, defaultConfig, config, envConfig);
158+
config = extend(true, {}, defaultConfig, config, envConfig);
159159

160160
if (config.keyFilename || config.credentials || config.projectId) {
161161
throw new Error('keyFilename, projectId or credentials should be provided' +

test/test-debuglet.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ describe('Debuglet', function() {
5858

5959
afterEach(function() { nock.cleanAll(); });
6060

61+
it('should merge config correctly', function() {
62+
var debug = require('../src/debug.js')();
63+
64+
var testValue = 2 * defaultConfig.capture.maxExpandFrames;
65+
var config = {capture: {maxExpandFrames: testValue}};
66+
var debuglet = new Debuglet(debug, config);
67+
68+
// The actual config should be exactly defaultConfig with only
69+
// maxExpandFrames adjusted.
70+
var compareConfig = extend(true, {}, defaultConfig);
71+
compareConfig.capture.maxExpandFrames = testValue;
72+
assert.deepEqual(debuglet.config_, compareConfig);
73+
});
74+
6175
it('should not start when projectId is not available', function(done) {
6276
this.timeout(8000);
6377
var debug = require('../src/debug.js')();

0 commit comments

Comments
 (0)