@@ -108,7 +108,6 @@ export type Script = {
108
108
export type ScriptWithSourceMapHandler = (
109
109
script : Script ,
110
110
sources : Source [ ] ,
111
- brokenOn ?: Cdp . Debugger . Location ,
112
111
) => Promise < IUiLocation [ ] > ;
113
112
export type SourceMapDisabler = ( hitBreakpoints : string [ ] ) => ISourceWithMap [ ] ;
114
113
@@ -147,6 +146,13 @@ const getReplSourceSuffix = () =>
147
146
sourceUtils . SourceConstants . ReplExtension
148
147
} \n`;
149
148
149
+ /** Auxillary data present in Cdp.Debugger.Paused events in recent Chrome versions */
150
+ interface IInstrumentationPauseAuxData {
151
+ scriptId : string ;
152
+ url : string ;
153
+ sourceMapURL : string ;
154
+ }
155
+
150
156
export class Thread implements IVariableStoreLocationProvider {
151
157
private static _lastThreadId = 0 ;
152
158
public readonly id : number ;
@@ -807,11 +813,11 @@ export class Thread implements IVariableStoreLocationProvider {
807
813
// https://github.com/denoland/deno/blob/2703996dea73c496d79fcedf165886a1659622d1/core/inspector.rs#L571
808
814
const isInspectBrk =
809
815
( event . reason as string ) === 'Break on start' || event . reason === 'debugCommand' ;
810
- const location = event . callFrames [ 0 ] . location ;
811
- const scriptId = event . data ?. scriptId || location . scriptId ;
816
+ const location = event . callFrames [ 0 ] ? .location as Cdp . Debugger . Location | undefined ;
817
+ const scriptId = ( event . data as IInstrumentationPauseAuxData ) ?. scriptId || location ? .scriptId ;
812
818
const isSourceMapPause =
813
819
( event . reason === 'instrumentation' && event . data ?. scriptId ) ||
814
- this . _breakpointManager . isEntrypointBreak ( hitBreakpoints , scriptId ) ;
820
+ ( scriptId && this . _breakpointManager . isEntrypointBreak ( hitBreakpoints , scriptId ) ) ;
815
821
this . evaluator . setReturnedValue ( event . callFrames [ 0 ] ?. returnValue ) ;
816
822
817
823
if ( isSourceMapPause ) {
@@ -826,7 +832,7 @@ export class Thread implements IVariableStoreLocationProvider {
826
832
event . data . __rewriteAs = 'breakpoint' ;
827
833
}
828
834
829
- if ( await this . _handleSourceMapPause ( scriptId , location ) ) {
835
+ if ( scriptId && ( await this . _handleSourceMapPause ( scriptId , location ) ) ) {
830
836
// Pause if we just resolved a breakpoint that's on this
831
837
// location; this won't have existed before now.
832
838
} else if ( isInspectBrk ) {
@@ -1483,7 +1489,10 @@ export class Thread implements IVariableStoreLocationProvider {
1483
1489
* Wait for source map to load and set all breakpoints in this particular
1484
1490
* script. Returns true if the debugger should remain paused.
1485
1491
*/
1486
- async _handleSourceMapPause ( scriptId : string , brokenOn : Cdp . Debugger . Location ) : Promise < boolean > {
1492
+ async _handleSourceMapPause (
1493
+ scriptId : string ,
1494
+ brokenOn ?: Cdp . Debugger . Location ,
1495
+ ) : Promise < boolean > {
1487
1496
this . _pausedForSourceMapScriptId = scriptId ;
1488
1497
const perScriptTimeout = this . _sourceContainer . sourceMapTimeouts ( ) . sourceMapMinPause ;
1489
1498
const timeout =
@@ -1496,10 +1505,7 @@ export class Thread implements IVariableStoreLocationProvider {
1496
1505
}
1497
1506
1498
1507
const timer = new HrTime ( ) ;
1499
- const result = await Promise . race ( [
1500
- this . _getOrStartLoadingSourceMaps ( script , brokenOn ) ,
1501
- delay ( timeout ) ,
1502
- ] ) ;
1508
+ const result = await Promise . race ( [ this . _getOrStartLoadingSourceMaps ( script ) , delay ( timeout ) ] ) ;
1503
1509
1504
1510
const timeSpentWallClockInMs = timer . elapsed ( ) . ms ;
1505
1511
const sourceMapCumulativePause =
@@ -1530,24 +1536,20 @@ export class Thread implements IVariableStoreLocationProvider {
1530
1536
console . assert ( this . _pausedForSourceMapScriptId === scriptId ) ;
1531
1537
this . _pausedForSourceMapScriptId = undefined ;
1532
1538
1533
- return (
1534
- ! ! result &&
1535
- result
1536
- . map ( base1To0 )
1537
- . some (
1538
- b =>
1539
- b . lineNumber === brokenOn . lineNumber &&
1540
- ( brokenOn . columnNumber === undefined || brokenOn . columnNumber === b . columnNumber ) ,
1541
- )
1542
- ) ;
1539
+ const bLine = brokenOn ?. lineNumber || 0 ;
1540
+ const bColumn = brokenOn ?. columnNumber ;
1541
+
1542
+ return ! ! result
1543
+ ?. map ( base1To0 )
1544
+ . some ( b => b . lineNumber === bLine && ( bColumn === undefined || bColumn === b . columnNumber ) ) ;
1543
1545
}
1544
1546
1545
1547
/**
1546
1548
* Loads sourcemaps for the given script and invokes the handler, if we
1547
1549
* haven't already done so. Returns a promise that resolves with the
1548
1550
* handler's results.
1549
1551
*/
1550
- private _getOrStartLoadingSourceMaps ( script : Script , brokenOn ?: Cdp . Debugger . Location ) {
1552
+ private _getOrStartLoadingSourceMaps ( script : Script ) {
1551
1553
const existing = this . _sourceMapLoads . get ( script . scriptId ) ;
1552
1554
if ( existing ) {
1553
1555
return existing ;
@@ -1557,7 +1559,7 @@ export class Thread implements IVariableStoreLocationProvider {
1557
1559
. then ( source => this . _sourceContainer . waitForSourceMapSources ( source ) )
1558
1560
. then ( sources =>
1559
1561
sources . length && this . _scriptWithSourceMapHandler
1560
- ? this . _scriptWithSourceMapHandler ( script , sources , brokenOn )
1562
+ ? this . _scriptWithSourceMapHandler ( script , sources )
1561
1563
: [ ] ,
1562
1564
) ;
1563
1565
0 commit comments