Skip to content

Commit

Permalink
fix: eval webpack config breakpoints not setting
Browse files Browse the repository at this point in the history
V8 does not resolve URL-set breakpoints when the script in question only
has that URL via a sourceURL mapping.

For  microsoft/vscode#194988
  • Loading branch information
connor4312 committed Oct 6, 2023
1 parent eb98953 commit 1de054f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/adapter/breakpoints/breakpointBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ export abstract class Breakpoint {
bp.args.location.scriptId === script.scriptId &&
lcEqual(bp.args.location, lineColumn)) ||
(script.url &&
!script.hasSourceURL &&
isSetByUrl(bp.args) &&
(bp.args.urlRegex
? new RegExp(bp.args.urlRegex).test(script.url)
Expand Down Expand Up @@ -560,8 +561,9 @@ export abstract class Breakpoint {

protected async _setForSpecific(thread: Thread, script: ISourceScript, lineColumn: LineColumn) {
// prefer to set on script URL for non-anonymous scripts, since url breakpoints
// will survive and be hit on reload.
if (script.url) {
// will survive and be hit on reload. But don't set if the script has
// a source URL, since V8 doesn't resolve these
if (script.url && !script.hasSourceURL) {
return this._setByUrl(thread, script.url, lineColumn);
} else {
return this._setByScriptId(thread, script, lineColumn);
Expand Down
1 change: 1 addition & 0 deletions src/adapter/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export interface IWasmLocationProvider extends ISourceLocationProvider {
export interface ISourceScript {
executionContextId: Cdp.Runtime.ExecutionContextId;
scriptId: Cdp.Runtime.ScriptId;
hasSourceURL: boolean;
url: string;
}

Expand Down
17 changes: 12 additions & 5 deletions src/adapter/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ import * as objectPreview from './objectPreview';
import { PreviewContextType, getContextForType } from './objectPreview/contexts';
import { ExpectedPauseReason, IPausedDetails, StepDirection } from './pause';
import { SmartStepper } from './smartStepping';
import { ISourceWithMap, IUiLocation, Source, base1To0, isSourceWithWasm } from './source';
import {
ISourceScript,
ISourceWithMap,
IUiLocation,
Source,
base1To0,
isSourceWithWasm,
} from './source';
import { IPreferredUiLocation, SourceContainer } from './sourceContainer';
import { InlinedFrame, StackFrame, StackTrace, isStackFrameElement } from './stackTrace';
import {
Expand Down Expand Up @@ -69,10 +76,7 @@ export class ExecutionContext {
}
}

export type Script = {
url: string;
scriptId: string;
executionContextId: number;
export type Script = ISourceScript & {
source: Promise<Source>;
resolvedSource?: Source;
};
Expand Down Expand Up @@ -1515,6 +1519,7 @@ export class Thread implements IVariableStoreLocationProvider {
prevSource.addScript({
scriptId: event.scriptId,
url: event.url,
hasSourceURL: !!event.hasSourceURL,
executionContextId: event.executionContextId,
});
return prevSource;
Expand Down Expand Up @@ -1565,6 +1570,7 @@ export class Thread implements IVariableStoreLocationProvider {
source.addScript({
scriptId: event.scriptId,
url: event.url,
hasSourceURL: !!event.hasSourceURL,
executionContextId: event.executionContextId,
});

Expand All @@ -1573,6 +1579,7 @@ export class Thread implements IVariableStoreLocationProvider {

const script: Script = {
url: event.url,
hasSourceURL: !!event.hasSourceURL,
scriptId: event.scriptId,
executionContextId: event.executionContextId,
source: createSource(),
Expand Down

0 comments on commit 1de054f

Please sign in to comment.