From e9b53c7d09763f042455b04383c9038475a495a9 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Thu, 2 Mar 2023 14:15:59 -0800 Subject: [PATCH 1/3] fix: cannot read property error Seems like esbuild doesn't deal with const enums in dependency .d.ts like ts does --- .husky/pre-commit | 2 +- package.json | 1 + src/targets/browser/browserLauncher.ts | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 3622d7050..84aacf945 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npm run test:lint && npm run test:types +npm run -S precommit diff --git a/package.json b/package.json index 7ffc94739..c0c7ac171 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "prepare": "husky install", "package": "gulp package", "publish": "gulp publish", + "precommit": "npm-run-all --parallel test:lint test:types", "updatetypes": "cd src/typings && npx vscode-dts dev && npx vscode-dts master", "updatenodeapi": "python src/build/getNodePdl.py && prettier --write src/build/nodeCustom.ts", "generateapis": "node dist/src/build/generateDap.js && node dist/src/build/generateCdp.js", diff --git a/src/targets/browser/browserLauncher.ts b/src/targets/browser/browserLauncher.ts index af71e48e3..de9298c27 100644 --- a/src/targets/browser/browserLauncher.ts +++ b/src/targets/browser/browserLauncher.ts @@ -2,7 +2,7 @@ * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ -import { IBrowserFinder, isQuality, Quality } from '@vscode/js-debug-browsers'; +import { IBrowserFinder, isQuality } from '@vscode/js-debug-browsers'; import * as fs from 'fs'; import { inject, injectable } from 'inversify'; import * as path from 'path'; @@ -92,7 +92,7 @@ export abstract class BrowserLauncher telemetryReporter: ITelemetryReporter, promisedPort?: Promise, ): Promise { - const executablePath = await this.findBrowserPath(executable || Quality.Stable); + const executablePath = await this.findBrowserPath(executable || 'stable'); // If we had a custom executable, don't resolve a data // dir unless it's explicitly requested. @@ -298,7 +298,7 @@ export abstract class BrowserLauncher // try to find the stable browser, but if that fails just get any browser // that's available on the system const found = - (await finder.findWhere(r => r.quality === Quality.Stable)) || (await finder.findAll())[0]; + (await finder.findWhere(r => r.quality === 'stable')) || (await finder.findAll())[0]; return found?.path; } else if (isQuality(executablePath)) { return (await finder.findWhere(r => r.quality === executablePath))?.path; From 2bf3f18024b142c485722530171502bef81d6571 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Thu, 2 Mar 2023 16:39:21 -0800 Subject: [PATCH 2/3] fix: assorted bad source behaviors when reloading a page Fixes #1582 --- CHANGELOG.md | 1 + src/adapter/breakpoints.ts | 19 ++-- src/adapter/breakpoints/breakpointBase.ts | 20 ++-- src/adapter/diagnosics.ts | 2 +- src/adapter/scriptSkipper/implementation.ts | 26 +++-- src/adapter/sources.ts | 43 ++++++-- src/adapter/threads.ts | 99 ++++++++++--------- ...s-with-removed-execution-contexts-1582.txt | 27 +++++ src/test/breakpoints/breakpointsTest.ts | 25 +++++ testWorkspace/web/iframe-1582/index.html | 12 +++ testWorkspace/web/iframe-1582/inner.html | 12 +++ testWorkspace/web/iframe-1582/inner.js | 4 + 12 files changed, 204 insertions(+), 86 deletions(-) create mode 100644 src/test/breakpoints/breakpoints-deals-with-removed-execution-contexts-1582.txt create mode 100644 testWorkspace/web/iframe-1582/index.html create mode 100644 testWorkspace/web/iframe-1582/inner.html create mode 100644 testWorkspace/web/iframe-1582/inner.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e6b07cdc..605a12030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he - fix: repl stacktrace with renames showing too much info ([#1259](https://github.com/microsoft/vscode-js-debug/issues/1259#issuecomment-1409443564)) - fix: recursive source map resolution parsing ignored locations ([vscode#169733](https://github.com/microsoft/vscode/issues/169733)) - fix: unbound breakpoints in sourcemaps on Chrome 112 ([#1567](https://github.com/microsoft/vscode-js-debug/issues/1567)) +- fix: assorted bad source behaviors when reloading a page ([#1582](https://github.com/microsoft/vscode-js-debug/issues/1582)) - chore: remove webpack, adopt esbuild ## v1.76 (February 2023) diff --git a/src/adapter/breakpoints.ts b/src/adapter/breakpoints.ts index bcf3cd201..45ba4e71d 100644 --- a/src/adapter/breakpoints.ts +++ b/src/adapter/breakpoints.ts @@ -26,17 +26,17 @@ import { PatternEntryBreakpoint } from './breakpoints/patternEntrypointBreakpoin import { UserDefinedBreakpoint } from './breakpoints/userDefinedBreakpoint'; import { DiagnosticToolSuggester } from './diagnosticToolSuggester'; import { - base0To1, - base1To0, ISourceWithMap, - isSourceWithMap, IUiLocation, - rawToUiOffset, Source, SourceContainer, + base0To1, + base1To0, + isSourceWithMap, + rawToUiOffset, uiToRawOffset, } from './sources'; -import { Script, ScriptWithSourceMapHandler, Thread } from './threads'; +import { ScriptWithSourceMapHandler, Thread } from './threads'; /** * Differential result used internally in setBreakpoints. @@ -348,16 +348,15 @@ export class BreakpointManager { continue; } - // Only take the first script that matches this source. The breakpoints + // Only take the last script that matches this source. The breakpoints // are all coming from the same source code, so possible breakpoints // at one location where this source is present should match every other. const lsrc = start.source; - const scripts = thread.scriptsFromSource(lsrc); - if (scripts.size === 0) { + if (!lsrc.scripts.length) { continue; } - const { scriptId } = scripts.values().next().value as Script; + const { scriptId } = lsrc.scripts[lsrc.scripts.length - 1]; todo.push( thread .cdp() @@ -610,7 +609,7 @@ export class BreakpointManager { await Promise.all( result.unbound.map(b => { this._byDapId.delete(b.dapId); - b.disable(); + return b.disable(); }), ); diff --git a/src/adapter/breakpoints/breakpointBase.ts b/src/adapter/breakpoints/breakpointBase.ts index 8abc51a1b..33e9af0a1 100644 --- a/src/adapter/breakpoints/breakpointBase.ts +++ b/src/adapter/breakpoints/breakpointBase.ts @@ -7,7 +7,14 @@ import { LogTag } from '../../common/logging'; import { absolutePathToFileUrl, urlToRegex } from '../../common/urlUtils'; import Dap from '../../dap/api'; import { BreakpointManager } from '../breakpoints'; -import { base1To0, IUiLocation, Source, SourceFromMap, uiToRawOffset } from '../sources'; +import { + base1To0, + ISourceScript, + IUiLocation, + Source, + SourceFromMap, + uiToRawOffset, +} from '../sources'; import { Script, Thread } from '../threads'; export type LineColumn = { lineNumber: number; columnNumber: number }; // 1-based @@ -451,10 +458,9 @@ export abstract class Breakpoint { } private async _setByUiLocation(thread: Thread, uiLocation: IUiLocation): Promise { - const promises: Promise[] = []; - const scripts = thread.scriptsFromSource(uiLocation.source); - for (const script of scripts) promises.push(this._setByScriptId(thread, script, uiLocation)); - await Promise.all(promises); + await Promise.all( + uiLocation.source.scripts.map(script => this._setByScriptId(thread, script, uiLocation)), + ); } protected async _setByPath(thread: Thread, lineColumn: LineColumn): Promise { @@ -503,7 +509,7 @@ export abstract class Breakpoint { * requests to avoid triggering any logpoint breakpoints multiple times, * as would happen if we set a breakpoint both by script and URL. */ - protected hasSetOnLocation(script: Partial + + diff --git a/testWorkspace/web/iframe-1582/inner.js b/testWorkspace/web/iframe-1582/inner.js new file mode 100644 index 000000000..35ad40cf7 --- /dev/null +++ b/testWorkspace/web/iframe-1582/inner.js @@ -0,0 +1,4 @@ +let i = 0; +setInterval(() => { + i++; +}, 50); From 2209ba5a8b5358d3b7d77449cb9cc92abdb524bd Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Fri, 3 Mar 2023 09:03:29 -0800 Subject: [PATCH 3/3] bump build bot