From deb1d0239fcdcdb9708170404da55fe0c491fe3e Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 18 Mar 2024 23:45:54 +0000 Subject: [PATCH 1/2] fix(node): Record local variables with falsy values (v7) --- .../LocalVariables/local-variables-caught.js | 3 +++ .../LocalVariables/local-variables-caught.mjs | 3 +++ .../local-variables-memory-test.js | 3 +++ .../LocalVariables/local-variables.js | 3 +++ .../LocalVariables/no-local-variables.js | 3 +++ .../suites/public-api/LocalVariables/test.ts | 3 +++ .../local-variables/local-variables-async.ts | 6 +++--- .../local-variables/local-variables-sync.ts | 17 +++++++++-------- 8 files changed, 30 insertions(+), 11 deletions(-) diff --git a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.js b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.js index 7c86004da43b..17923fe3ca46 100644 --- a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.js +++ b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.js @@ -20,6 +20,9 @@ function one(name) { name, num: 5, }; + const bool = false; + const num = 0; + const str = ''; const ty = new Some(); diff --git a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.mjs b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.mjs index 37e5966bc575..ed6032a0b84d 100644 --- a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.mjs +++ b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-caught.mjs @@ -22,6 +22,9 @@ function one(name) { functionsShouldNotBeIncluded: () => {}, functionsShouldNotBeIncluded2() {}, }; + const bool = false; + const num = 0; + const str = ''; const ty = new Some(); diff --git a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-memory-test.js b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-memory-test.js index 7aa9feb9ae2a..4d88a85a17a3 100644 --- a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-memory-test.js +++ b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables-memory-test.js @@ -22,6 +22,9 @@ function one(name) { name, num: 5, }; + const bool = false; + const num = 0; + const str = ''; const ty = new Some(); diff --git a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js index 4a16ad89b5aa..11ebbd610fb0 100644 --- a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js +++ b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/local-variables.js @@ -24,6 +24,9 @@ function one(name) { name, num: 5, }; + const bool = false; + const num = 0; + const str = ''; const ty = new Some(); diff --git a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js index f01e33a9cafa..88dadf0f853f 100644 --- a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js +++ b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/no-local-variables.js @@ -23,6 +23,9 @@ function one(name) { name, num: 5, }; + const bool = false; + const num = 0; + const str = ''; const ty = new Some(); diff --git a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts index 3458d74f46b1..9fa649fe4106 100644 --- a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts @@ -16,6 +16,9 @@ const EXPECTED_LOCAL_VARIABLES_EVENT = { arr: [1, '2', null], obj: { name: 'some name', num: 5 }, ty: '', + bool: false, + num: 0, + str: '', }, }), expect.objectContaining({ diff --git a/packages/node/src/integrations/local-variables/local-variables-async.ts b/packages/node/src/integrations/local-variables/local-variables-async.ts index b5f015b2b7db..7b6ae38db292 100644 --- a/packages/node/src/integrations/local-variables/local-variables-async.ts +++ b/packages/node/src/integrations/local-variables/local-variables-async.ts @@ -42,9 +42,9 @@ async function unrollObject(session: Session, objectId: string, name: string, va } function unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables): void { - if (prop?.value?.value) { + if (prop?.value?.value != null) { vars[prop.name] = prop.value.value; - } else if (prop?.value?.description && prop?.value?.type !== 'function') { + } else if (prop?.value?.description != null && prop?.value?.type !== 'function') { vars[prop.name] = `<${prop.value.description}>`; } } @@ -63,7 +63,7 @@ async function getLocalVariables(session: Session, objectId: string): Promise this._unrollObject(id, prop.name, vars, next)); - } else if (prop?.value?.value || prop?.value?.description) { + } else if (prop?.value?.value != null || prop?.value?.description != null) { add(vars => this._unrollOther(prop, vars, next)); } } @@ -192,9 +192,9 @@ class AsyncSession implements DebugSession { * Unrolls other properties */ private _unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables, next: (vars: Variables) => void): void { - if (prop?.value?.value) { + if (prop?.value?.value != null) { vars[prop.name] = prop.value.value; - } else if (prop?.value?.description && prop?.value?.type !== 'function') { + } else if (prop?.value?.description != null && prop?.value?.type !== 'function') { vars[prop.name] = `<${prop.value.description}>`; } @@ -269,11 +269,12 @@ const _localVariablesSyncIntegration = (( }); } else { const id = localScope.object.objectId; - add(frames => - session?.getLocalVariables(id, vars => { - frames[i] = { function: fn, vars }; - next(frames); - }), + add( + frames => + session?.getLocalVariables(id, vars => { + frames[i] = { function: fn, vars }; + next(frames); + }), ); } } From 318e3cf73d5766348112dfc04fc01319fa619468 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Tue, 19 Mar 2024 10:17:46 +0000 Subject: [PATCH 2/2] Linting --- .../local-variables/local-variables-sync.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/node/src/integrations/local-variables/local-variables-sync.ts b/packages/node/src/integrations/local-variables/local-variables-sync.ts index 2394ec5b3862..1aa827c55714 100644 --- a/packages/node/src/integrations/local-variables/local-variables-sync.ts +++ b/packages/node/src/integrations/local-variables/local-variables-sync.ts @@ -269,12 +269,11 @@ const _localVariablesSyncIntegration = (( }); } else { const id = localScope.object.objectId; - add( - frames => - session?.getLocalVariables(id, vars => { - frames[i] = { function: fn, vars }; - next(frames); - }), + add(frames => + session?.getLocalVariables(id, vars => { + frames[i] = { function: fn, vars }; + next(frames); + }), ); } }