Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: disable entrypoint breakpoint at first pause in script #2094

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/adapter/breakpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,19 @@ export class BreakpointManager {
});
}

/**
* Disables entrypoint breakpoints set in the given script ID. This is
* needed so they don't vote to continue later
* @see https://github.com/microsoft/vscode/issues/230201
*/
public async disableEntrypointBreaks(scriptId: string) {
await Promise.all([...this.moduleEntryBreakpoints.values()].map(bp => {
if (bp.enabled && bp.cdpScriptIds.has(scriptId)) {
return bp.disable();
}
}));
}

/** Gets whether the CDP breakpoint ID refers to an entrypoint breakpoint. */
public isEntrypointCdpBreak(cdpId: string) {
const bp = this._resolvedBreakpoints.get(cdpId);
Expand Down
2 changes: 2 additions & 0 deletions src/adapter/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,7 @@ export class Thread implements IVariableStoreLocationProvider {
}

const timer = new HrTime();
const disableProm = this._breakpointManager.disableEntrypointBreaks(scriptId);
const result = await Promise.race([this._getOrStartLoadingSourceMaps(script), delay(timeout)]);

const timeSpentWallClockInMs = timer.elapsed().ms;
Expand Down Expand Up @@ -1751,6 +1752,7 @@ export class Thread implements IVariableStoreLocationProvider {

console.assert(this._pausedForSourceMapScriptId === scriptId);
this._pausedForSourceMapScriptId = undefined;
await disableProm;

const bLine = brokenOn?.lineNumber || 0;
const bColumn = brokenOn?.columnNumber;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
allThreadsStopped : false
description : Paused
reason : step
threadId : <number>
}
<anonymous> @ ${fixturesDir}/test.js:5:1
25 changes: 25 additions & 0 deletions src/test/breakpoints/breakpointsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1414,4 +1414,29 @@ describe('breakpoints', () => {
await waitForPause(p);
p.assertLog();
});

itIntegrates('disables entrypoint breakpoint when in file (vscode#230201)', async ({ r }) => {
createFileTree(testFixturesDir, {
'test.js': `function firstfunc(arg){
return arg * arg
}
const a = firstfunc(2);
console.log('Finished awesome program');`,
});

const handle = await r.runScript('test.js', {
cwd: testFixturesDir,
});

await handle.dap.setBreakpoints({
source: { path: join(testFixturesDir, 'test.js') },
breakpoints: [{ line: 4, column: 1 }],
});

handle.load();
const { threadId } = await handle.dap.once('stopped');
await handle.dap.next({ threadId: threadId! });
await waitForPause(handle);
r.assertLog({ substring: true });
});
});
Loading