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

Commit e322b6c

Browse files
authored
fix: warn if maxDataSize=0 (#744)
Also, this is not reported in breakpoints in Node 12+, so modify a test to reflect this.
1 parent 444e321 commit e322b6c

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/agent/debuglet.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ const NODE_VERSION_MESSAGE =
5454
'Node.js version not supported. Node.js 5.2.0 and ' +
5555
'versions older than 0.12 are not supported.';
5656
const NODE_10_CIRC_REF_MESSAGE =
57-
'capture.maxDataSize=0 is not recommended on older versions of Node' +
58-
' 10/11. See https://github.com/googleapis/cloud-debug-nodejs/issues/516' +
59-
' for more information.';
57+
'capture.maxDataSize=0 is not recommended on older versions of Node 10/11' +
58+
' and Node 12.' +
59+
' See https://github.com/googleapis/cloud-debug-nodejs/issues/516 for more' +
60+
' information.';
6061
const BREAKPOINT_ACTION_MESSAGE =
6162
'The only currently supported breakpoint actions' + ' are CAPTURE and LOG.';
6263

@@ -453,7 +454,7 @@ export class Debuglet extends EventEmitter {
453454
if (
454455
this.config.capture &&
455456
this.config.capture.maxDataSize === 0 &&
456-
utils.satisfies(process.version, '>=10 <10.15.3 || >=11 <11.7')
457+
utils.satisfies(process.version, '>=10 <10.15.3 || >=11 <11.7 || >=12')
457458
) {
458459
that.logger.warn(NODE_10_CIRC_REF_MESSAGE);
459460
}

test/test-circular.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import * as debugapi from '../src/agent/v8/debugapi';
2525
import consoleLogLevel = require('console-log-level');
2626
import * as stackdriver from '../src/types/stackdriver';
2727
import {Variable} from '../src/types/stackdriver';
28+
import {satisfies} from '../src/agent/util/utils';
2829

2930
const code = require('./test-circular-code.js');
3031

@@ -42,7 +43,19 @@ function stateIsClean(api: debugapi.DebugApi): boolean {
4243
return true;
4344
}
4445

45-
describe(__filename, () => {
46+
/**
47+
* Stable object ID was reverted in V8 7.3 (Node 12), so circular objects will
48+
* not work in the near future. For now, we warn if the user specifies
49+
* maxDataSize = 0, as this will cause the app to crash.
50+
*/
51+
const maybeDescribe = satisfies(
52+
process.version,
53+
'>=10 <10.15.3 || >=11 <11.7 || >=12'
54+
)
55+
? describe.skip
56+
: describe;
57+
58+
maybeDescribe(__filename, () => {
4659
const config = Object.assign({}, defaultConfig, {
4760
workingDirectory: __dirname,
4861
forceNewAgent_: true,
@@ -76,8 +89,6 @@ describe(__filename, () => {
7689
afterEach(() => {
7790
assert(stateIsClean(api));
7891
});
79-
// TODO(kjin): Re-enable this test after issue #742 has been addressed
80-
/*
8192
it('Should be able to read the argument and the context', done => {
8293
// TODO: Have this actually implement Breakpoint
8394
const brk: stackdriver.Breakpoint = {
@@ -142,5 +153,4 @@ describe(__filename, () => {
142153
process.nextTick(code.foo.bind({}));
143154
});
144155
});
145-
*/
146156
});

test/test-this-context.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ describe(__filename, () => {
7878
afterEach(() => {
7979
assert(stateIsClean(api));
8080
});
81-
// TODO(kjin): Re-enable this test after issue #742 has been addressed
82-
/*
8381
it('Should be able to read the argument and the context', done => {
8482
// TODO: Have this actually implement Breakpoint
8583
const brk: stackdriver.Breakpoint = {
@@ -104,7 +102,7 @@ describe(__filename, () => {
104102
);
105103
assert.deepStrictEqual(ctxMembers![0], {name: 'a', value: '10'});
106104
assert.strictEqual(args.length, 0, 'There should be zero arguments');
107-
if (utils.satisfies(process.version, '>=11')) {
105+
if (utils.satisfies(process.version, '>=11 && <12')) {
108106
assert.strictEqual(locals.length, 3, 'There should be three locals');
109107
assert.deepStrictEqual(locals[0].name, 'this');
110108
assert.deepStrictEqual(locals[1], {name: 'b', value: '1'});
@@ -122,7 +120,6 @@ describe(__filename, () => {
122120
process.nextTick(code.foo.bind({}, 1));
123121
});
124122
});
125-
*/
126123
it('Should be able to read the argument and deny the context', done => {
127124
// TODO: Have this actually implement Breakpoint
128125
const brk = {

0 commit comments

Comments
 (0)