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..8ea8dd93fb4d 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,11 @@ function one(name) { name, num: 5, }; + const bool = false; + const num = 0; + const str = ''; + const something = undefined; + const somethingElse = null; 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..a7427ac60157 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,11 @@ function one(name) { functionsShouldNotBeIncluded: () => {}, functionsShouldNotBeIncluded2() {}, }; + const bool = false; + const num = 0; + const str = ''; + const something = undefined; + const somethingElse = null; 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 58d838ae08cf..35c71a3fc6e8 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,11 @@ function one(name) { name, num: 5, }; + const bool = false; + const num = 0; + const str = ''; + const something = undefined; + const somethingElse = null; 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..8b64c80cbc5f 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,11 @@ function one(name) { name, num: 5, }; + const bool = false; + const num = 0; + const str = ''; + const something = undefined; + const somethingElse = null; 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..2857fc0e3ce9 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,11 @@ function one(name) { name, num: 5, }; + const bool = false; + const num = 0; + const str = ''; + const something = undefined; + const somethingElse = null; 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 50dd06dfcd3b..3a8d904de3c9 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,11 @@ const EXPECTED_LOCAL_VARIABLES_EVENT = { arr: [1, '2', null], obj: { name: 'some name', num: 5 }, ty: '', + bool: false, + num: 0, + str: '', + something: '', + somethingElse: '', }, }), expect.objectContaining({ diff --git a/packages/node-experimental/src/integrations/local-variables/local-variables-async.ts b/packages/node-experimental/src/integrations/local-variables/local-variables-async.ts index db065466e82a..baeeb4866be4 100644 --- a/packages/node-experimental/src/integrations/local-variables/local-variables-async.ts +++ b/packages/node-experimental/src/integrations/local-variables/local-variables-async.ts @@ -42,10 +42,20 @@ async function unrollObject(session: Session, objectId: string, name: string, va } function unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables): void { - if (prop?.value?.value) { - vars[prop.name] = prop.value.value; - } else if (prop?.value?.description && prop?.value?.type !== 'function') { + if (!prop.value) { + return; + } + + if ('value' in prop.value) { + if (prop.value.value === undefined || prop.value.value === null) { + vars[prop.name] = `<${prop.value.value}>`; + } else { + vars[prop.name] = prop.value.value; + } + } else if ('description' in prop.value && prop.value.type !== 'function') { vars[prop.name] = `<${prop.value.description}>`; + } else if (prop.value.type === 'undefined') { + vars[prop.name] = ''; } } @@ -63,7 +73,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) { add(vars => this._unrollOther(prop, vars, next)); } } @@ -191,10 +191,18 @@ class AsyncSession implements DebugSession { * Unrolls other properties */ private _unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables, next: (vars: Variables) => void): void { - if (prop?.value?.value) { - vars[prop.name] = prop.value.value; - } else if (prop?.value?.description && prop?.value?.type !== 'function') { - vars[prop.name] = `<${prop.value.description}>`; + if (prop.value) { + if ('value' in prop.value) { + if (prop.value.value === undefined || prop.value.value === null) { + vars[prop.name] = `<${prop.value.value}>`; + } else { + vars[prop.name] = prop.value.value; + } + } else if ('description' in prop.value && prop.value.type !== 'function') { + vars[prop.name] = `<${prop.value.description}>`; + } else if (prop.value.type === 'undefined') { + vars[prop.name] = ''; + } } next(vars); 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 0d04f1f0b6e1..fee8937af91d 100644 --- a/packages/node/src/integrations/local-variables/local-variables-async.ts +++ b/packages/node/src/integrations/local-variables/local-variables-async.ts @@ -42,10 +42,20 @@ async function unrollObject(session: Session, objectId: string, name: string, va } function unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables): void { - if (prop?.value?.value) { - vars[prop.name] = prop.value.value; - } else if (prop?.value?.description && prop?.value?.type !== 'function') { + if (!prop.value) { + return; + } + + if ('value' in prop.value) { + if (prop.value.value === undefined || prop.value.value === null) { + vars[prop.name] = `<${prop.value.value}>`; + } else { + vars[prop.name] = prop.value.value; + } + } else if ('description' in prop.value && prop.value.type !== 'function') { vars[prop.name] = `<${prop.value.description}>`; + } else if (prop.value.type === 'undefined') { + vars[prop.name] = ''; } } @@ -63,7 +73,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) { add(vars => this._unrollOther(prop, vars, next)); } } @@ -192,10 +192,18 @@ class AsyncSession implements DebugSession { * Unrolls other properties */ private _unrollOther(prop: Runtime.PropertyDescriptor, vars: Variables, next: (vars: Variables) => void): void { - if (prop?.value?.value) { - vars[prop.name] = prop.value.value; - } else if (prop?.value?.description && prop?.value?.type !== 'function') { - vars[prop.name] = `<${prop.value.description}>`; + if (prop.value) { + if ('value' in prop.value) { + if (prop.value.value === undefined || prop.value.value === null) { + vars[prop.name] = `<${prop.value.value}>`; + } else { + vars[prop.name] = prop.value.value; + } + } else if ('description' in prop.value && prop.value.type !== 'function') { + vars[prop.name] = `<${prop.value.description}>`; + } else if (prop.value.type === 'undefined') { + vars[prop.name] = ''; + } } next(vars);