Skip to content

Commit c7306da

Browse files
authored
fix(node): Record local variables with falsy values (v7) (#11190)
Backport to v7 of #10821
1 parent 0e9cddf commit c7306da

File tree

8 files changed

+24
-6
lines changed

8 files changed

+24
-6
lines changed

dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ function one(name) {
2020
name,
2121
num: 5,
2222
};
23+
const bool = false;
24+
const num = 0;
25+
const str = '';
2326

2427
const ty = new Some();
2528

dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ function one(name) {
2222
functionsShouldNotBeIncluded: () => {},
2323
functionsShouldNotBeIncluded2() {},
2424
};
25+
const bool = false;
26+
const num = 0;
27+
const str = '';
2528

2629
const ty = new Some();
2730

dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-memory-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ function one(name) {
2222
name,
2323
num: 5,
2424
};
25+
const bool = false;
26+
const num = 0;
27+
const str = '';
2528

2629
const ty = new Some();
2730

dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ function one(name) {
2424
name,
2525
num: 5,
2626
};
27+
const bool = false;
28+
const num = 0;
29+
const str = '';
2730

2831
const ty = new Some();
2932

dev-packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ function one(name) {
2323
name,
2424
num: 5,
2525
};
26+
const bool = false;
27+
const num = 0;
28+
const str = '';
2629

2730
const ty = new Some();
2831

dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const EXPECTED_LOCAL_VARIABLES_EVENT = {
1616
arr: [1, '2', null],
1717
obj: { name: 'some name', num: 5 },
1818
ty: '<Some>',
19+
bool: false,
20+
num: 0,
21+
str: '',
1922
},
2023
}),
2124
expect.objectContaining({

packages/node/src/integrations/local-variables/local-variables-async.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ async function unrollObject(session: Session, objectId: string, name: string, va
4242
}
4343

4444
function unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables): void {
45-
if (prop?.value?.value) {
45+
if (prop?.value?.value != null) {
4646
vars[prop.name] = prop.value.value;
47-
} else if (prop?.value?.description && prop?.value?.type !== 'function') {
47+
} else if (prop?.value?.description != null && prop?.value?.type !== 'function') {
4848
vars[prop.name] = `<${prop.value.description}>`;
4949
}
5050
}
@@ -63,7 +63,7 @@ async function getLocalVariables(session: Session, objectId: string): Promise<Va
6363
} else if (prop?.value?.objectId && prop?.value?.className === 'Object') {
6464
const id = prop.value.objectId;
6565
await unrollObject(session, id, prop.name, variables);
66-
} else if (prop?.value?.value || prop?.value?.description) {
66+
} else if (prop?.value?.value != null || prop?.value?.description != null) {
6767
unrollOther(prop, variables);
6868
}
6969
}

packages/node/src/integrations/local-variables/local-variables-sync.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class AsyncSession implements DebugSession {
129129
} else if (prop?.value?.objectId && prop?.value?.className === 'Object') {
130130
const id = prop.value.objectId;
131131
add(vars => this._unrollObject(id, prop.name, vars, next));
132-
} else if (prop?.value?.value || prop?.value?.description) {
132+
} else if (prop?.value?.value != null || prop?.value?.description != null) {
133133
add(vars => this._unrollOther(prop, vars, next));
134134
}
135135
}
@@ -192,9 +192,9 @@ class AsyncSession implements DebugSession {
192192
* Unrolls other properties
193193
*/
194194
private _unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables, next: (vars: Variables) => void): void {
195-
if (prop?.value?.value) {
195+
if (prop?.value?.value != null) {
196196
vars[prop.name] = prop.value.value;
197-
} else if (prop?.value?.description && prop?.value?.type !== 'function') {
197+
} else if (prop?.value?.description != null && prop?.value?.type !== 'function') {
198198
vars[prop.name] = `<${prop.value.description}>`;
199199
}
200200

0 commit comments

Comments
 (0)