Skip to content

Commit

Permalink
fix: wasm breakpoint pausing not working on first run w/ predictor
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Oct 25, 2024
1 parent fea4d20 commit 3aca1ca
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/adapter/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1983,22 +1983,18 @@ export class Thread implements IVariableStoreLocationProvider {
handler?: ScriptWithSourceMapHandler,
): Promise<boolean> {
this._scriptWithSourceMapHandler = handler;

const needsPause = pause && this._sourceContainer.sourceMapTimeouts().sourceMapMinPause
&& handler;
if (needsPause && !this._pauseOnSourceMapBreakpointIds?.length) {
// setting the URL breakpoint for wasm fails if debugger isn't fully initialized
await this.debuggerReady.promise;

const wasmHandlers = Promise.all([...this._executionContexts.keys()]
.map(id => this._installWasmPauseHandler(id)));
const result = await Promise.all([
this._cdp.Debugger.setInstrumentationBreakpoint({
instrumentation: 'beforeScriptWithSourceMapExecution',
}),
]);
this._pauseOnSourceMapBreakpointIds = result.map(r => r?.breakpointId).filter(truthy);
await wasmHandlers;
} else if (!needsPause && this._pauseOnSourceMapBreakpointIds?.length) {
const breakpointIds = this._pauseOnSourceMapBreakpointIds;
this._pauseOnSourceMapBreakpointIds = undefined;
Expand All @@ -2007,6 +2003,14 @@ export class Thread implements IVariableStoreLocationProvider {
);
}

// WASM pauses should be unconditionally installed because DWARF parsing
// always happens at runtime, not in the brekapoint predictor (currently)
if (handler) {
await Promise.all(
[...this._executionContexts.keys()].map(id => this._installWasmPauseHandler(id)),
);
}

return !!this._pauseOnSourceMapBreakpointIds?.length;
}

Expand Down

0 comments on commit 3aca1ca

Please sign in to comment.