Skip to content

Commit fc778e6

Browse files
authored
fix: disable entrypoint breakpoint at first pause in script (#2094)
Fixes microsoft/vscode#230201
1 parent 868c088 commit fc778e6

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/adapter/breakpoints.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,19 @@ export class BreakpointManager {
714714
});
715715
}
716716

717+
/**
718+
* Disables entrypoint breakpoints set in the given script ID. This is
719+
* needed so they don't vote to continue later
720+
* @see https://github.com/microsoft/vscode/issues/230201
721+
*/
722+
public async disableEntrypointBreaks(scriptId: string) {
723+
await Promise.all([...this.moduleEntryBreakpoints.values()].map(bp => {
724+
if (bp.enabled && bp.cdpScriptIds.has(scriptId)) {
725+
return bp.disable();
726+
}
727+
}));
728+
}
729+
717730
/** Gets whether the CDP breakpoint ID refers to an entrypoint breakpoint. */
718731
public isEntrypointCdpBreak(cdpId: string) {
719732
const bp = this._resolvedBreakpoints.get(cdpId);

src/adapter/threads.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,6 +1721,7 @@ export class Thread implements IVariableStoreLocationProvider {
17211721
}
17221722

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

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

17521753
console.assert(this._pausedForSourceMapScriptId === scriptId);
17531754
this._pausedForSourceMapScriptId = undefined;
1755+
await disableProm;
17541756

17551757
const bLine = brokenOn?.lineNumber || 0;
17561758
const bColumn = brokenOn?.columnNumber;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
allThreadsStopped : false
3+
description : Paused
4+
reason : step
5+
threadId : <number>
6+
}
7+
<anonymous> @ ${fixturesDir}/test.js:5:1

src/test/breakpoints/breakpointsTest.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,4 +1414,29 @@ describe('breakpoints', () => {
14141414
await waitForPause(p);
14151415
p.assertLog();
14161416
});
1417+
1418+
itIntegrates('disables entrypoint breakpoint when in file (vscode#230201)', async ({ r }) => {
1419+
createFileTree(testFixturesDir, {
1420+
'test.js': `function firstfunc(arg){
1421+
return arg * arg
1422+
}
1423+
const a = firstfunc(2);
1424+
console.log('Finished awesome program');`,
1425+
});
1426+
1427+
const handle = await r.runScript('test.js', {
1428+
cwd: testFixturesDir,
1429+
});
1430+
1431+
await handle.dap.setBreakpoints({
1432+
source: { path: join(testFixturesDir, 'test.js') },
1433+
breakpoints: [{ line: 4, column: 1 }],
1434+
});
1435+
1436+
handle.load();
1437+
const { threadId } = await handle.dap.once('stopped');
1438+
await handle.dap.next({ threadId: threadId! });
1439+
await waitForPause(handle);
1440+
r.assertLog({ substring: true });
1441+
});
14171442
});

0 commit comments

Comments
 (0)