MCPcopy Create free account
hub / github.com/nodejs/node / handlePaused

Method handlePaused

lib/internal/debugger/inspect_probe.js:625–677  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

623 }
624
625 async handlePaused(params) {
626 if (this.finished) { return; }
627 // Ignore pauses that arrive before breakpoint setup is complete. Once
628 // startup is marked complete, `Runtime.runIfWaitingForDebugger` may surface
629 // the initial --inspect-brk pause, which the normal resume path handles.
630 if (!this.started) { return; }
631
632 const hitBreakpoints = params.hitBreakpoints;
633 if (hitBreakpoints === undefined || hitBreakpoints.length === 0) {
634 await this.resume();
635 return;
636 }
637
638 const topFrame = params.callFrames?.[0];
639 const callFrameId = topFrame?.callFrameId;
640 if (callFrameId === undefined) {
641 await this.resume();
642 return;
643 }
644
645 const { scriptId, lineNumber, columnNumber } = topFrame.location;
646 // `Debugger.scriptParsed` should always precede a pause for the same script.
647 // It should only be undefined if there's a bug (even in that case, just omit it).
648 const location = {
649 url: this.scriptIdToUrl.get(scriptId),
650 // CDP locations are 0-based, locations in public report are 1-based.
651 line: lineNumber + 1,
652 column: columnNumber + 1,
653 };
654 for (const breakpointId of hitBreakpoints) {
655 // The breakpoint ID is stable even for scripts parsed after the initial resolution
656 // so we can count on it here.
657 const definition = this.breakpointDefinitions.get(breakpointId);
658 if (definition === undefined) { continue; }
659
660 // Evaluate the expressions in the order they appear on the command line.
661 for (const probeIndex of definition.probeIndices) {
662 await this.evaluateProbe(callFrameId, probeIndex, location);
663 if (this.finished) { break; }
664 }
665 }
666
667 // Finish proactively as soon as any probe reaches its hit limit. All probes
668 // hit in this pause are recorded first, then the session ends.
669 // TODO(joyeecheung): When we implement attach mode, this teardown must
670 // resume-and-detach rather than kill, since the target is not ours.
671 if (!this.finished && ArrayPrototypeSome(this.probes, probeReachedLimit)) {
672 this.finishWithTrustedResult({ event: 'completed' });
673 return;
674 }
675
676 await this.resume();
677 }
678
679 async evaluateProbe(callFrameId, probeIndex, location) {
680 if (this.finished) { return; }

Callers 2

onPausedMethod · 0.95
testStartupPauseHandlingFunction · 0.80

Calls 4

resumeMethod · 0.95
evaluateProbeMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected