diff --git a/CHANGELOG.md b/CHANGELOG.md index 91fe75f1a..142c7814c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he ## Nightly (only) -Nothing, yet +- fix: error when processing private properties with a map ([#1824](https://github.com/microsoft/vscode-js-debug/issues/1824)) ## v1.83 (September 2023) diff --git a/src/adapter/variableStore.ts b/src/adapter/variableStore.ts index 6f73d2a02..9fd4c096e 100644 --- a/src/adapter/variableStore.ts +++ b/src/adapter/variableStore.ts @@ -854,9 +854,9 @@ class SetOrMapVariable extends ObjectVariable { constructor(context: VariableContext, remoteObject: Cdp.Runtime.RemoteObject) { super(context, remoteObject, NoCustomStringRepr); - const cast = remoteObject.preview as MapPreview | SetPreview; - this.isMap = cast.subtype === 'map'; - this.size = Number(cast.properties.find(p => p.name === 'size')?.value) ?? undefined; + this.isMap = remoteObject.subtype === 'map'; + const cast = remoteObject.preview as MapPreview | SetPreview | undefined; + this.size = Number(cast?.properties.find(p => p.name === 'size')?.value) ?? undefined; } public override async toDap(previewContext: PreviewContextType): Promise { diff --git a/src/test/variables/variables-map-variable-without-preview-1824.txt b/src/test/variables/variables-map-variable-without-preview-1824.txt new file mode 100644 index 000000000..880a256f6 --- /dev/null +++ b/src/test/variables/variables-map-variable-without-preview-1824.txt @@ -0,0 +1,3 @@ +> result: A {#bar: Map(1)} + > #bar: Map(1) + > [[Prototype]]: Object diff --git a/src/test/variables/variablesTest.ts b/src/test/variables/variablesTest.ts index 204bb37f2..6f94d22d6 100644 --- a/src/test/variables/variablesTest.ts +++ b/src/test/variables/variablesTest.ts @@ -421,6 +421,14 @@ describe('variables', () => { }); }); + itIntegrates('map variable without preview (#1824)', async ({ r }) => { + const p = await r.launchAndLoad('blank'); + await p.logger.evaluateAndLog(` + class A { #bar = new Map([[1, 2]]) } + new A();`); + p.assertLog(); + }); + itIntegrates('readMemory/writeMemory', async ({ r }) => { const p = await r.launchAndLoad('blank'); p.cdp.Runtime.evaluate({