(method, params, probe = null)
| 706 | } |
| 707 | |
| 708 | async callCdp(method, params, probe = null) { |
| 709 | if (this.finished) { throw kInspectorFailedSentinel; } |
| 710 | this.inFlight = { __proto__: null, method, probe }; |
| 711 | debug('CDP -> %s%s', method, probe !== null ? `, probe=${probe.index}` : ''); |
| 712 | try { |
| 713 | const result = await this.client.callMethod(method, params); |
| 714 | // A timeout or process exit can finish the report while the CDP request |
| 715 | // is still outstanding. Ignore the late reply in that case. |
| 716 | if (this.finished) { |
| 717 | debug('CDP <- %s discarded (already finished)', method); |
| 718 | throw kInspectorFailedSentinel; |
| 719 | } |
| 720 | debug('CDP <- %s (success)', method); |
| 721 | return result; |
| 722 | } catch (err) { |
| 723 | if (err !== kInspectorFailedSentinel) { // Already handled. |
| 724 | debug('CDP <- %s error: %s', method, err?.code); |
| 725 | } |
| 726 | if (this.disconnectRequested) { |
| 727 | // Only the in-flight evaluation gets attribution. Other rejections |
| 728 | // under disconnect are downstream noise. |
| 729 | if (probe !== null) { |
| 730 | this.recordInspectorFailure({ |
| 731 | reason: 'Target process exited during probe evaluation', |
| 732 | advice: kReviewProbeExprAdvice, |
| 733 | }); |
| 734 | } |
| 735 | throw kInspectorFailedSentinel; |
| 736 | } |
| 737 | // Another event handler already recorded the terminal event. |
| 738 | if (this.finished) { throw kInspectorFailedSentinel; } |
| 739 | if (!this.started) { |
| 740 | this.recordInspectorFailure({ |
| 741 | reason: 'Probe mode failed before user code ran', |
| 742 | advice: kStartupTeardownAdvice, |
| 743 | cdpError: err, |
| 744 | }); |
| 745 | } else if (method === 'Debugger.evaluateOnCallFrame') { |
| 746 | this.recordInspectorFailure({ |
| 747 | reason: 'The inspector could not evaluate a probe expression', |
| 748 | advice: `The rejection details are recorded on the probe hit. ${kReviewProbeExprAdvice}`, |
| 749 | cdpError: err, |
| 750 | }); |
| 751 | } else if (this.lastProbeIndex !== null) { |
| 752 | this.recordInspectorFailure({ |
| 753 | reason: 'Probe session failed after a probe evaluation', |
| 754 | advice: 'If the failure repeats, review the most-recently-evaluated probe expression.', |
| 755 | cdpError: err, |
| 756 | }); |
| 757 | } else { |
| 758 | this.recordInspectorFailure({ |
| 759 | reason: 'Probe session failed during inspector activity', |
| 760 | advice: 'This is likely a Node.js bug. Please file an issue.', |
| 761 | cdpError: err, |
| 762 | }); |
| 763 | } |
| 764 | throw kInspectorFailedSentinel; |
| 765 | } finally { |
no test coverage detected