@@ -12,6 +12,7 @@ import { Interceptor } from '.';
1212import { HtkConfig } from '../config' ;
1313import { delay } from '../util' ;
1414import { getTerminalEnvVars } from './terminal/terminal-env-overrides' ;
15+ import { reportError , addBreadcrumb } from '../error-tracking' ;
1516
1617const readFile = util . promisify ( fs . readFile ) ;
1718
@@ -67,6 +68,9 @@ export class ElectronInterceptor implements Interceptor {
6768
6869 this . debugClients [ proxyPort ] = this . debugClients [ proxyPort ] || [ ] ;
6970 this . debugClients [ proxyPort ] . push ( debugClient ) ;
71+ debugClient . once ( 'disconnect' , ( ) => {
72+ _ . remove ( this . debugClients [ proxyPort ] , c => c === debugClient ) ;
73+ } ) ;
7074
7175 const callFramePromise = new Promise < string > ( ( resolve ) => {
7276 debugClient ! . Debugger . paused ( ( stack ) => {
@@ -80,8 +84,8 @@ export class ElectronInterceptor implements Interceptor {
8084
8185 const callFrameId = await callFramePromise ;
8286
83- // Patch in our various module overrides:
84- await debugClient . Debugger . evaluateOnCallFrame ( {
87+ // Inside the Electron process, load our electron-intercepting JS.
88+ const injectionResult = await debugClient . Debugger . evaluateOnCallFrame ( {
8589 expression : `require("${
8690 // Inside the Electron process, load our electron-intercepting JS
8791 require . resolve ( '../../overrides/js/prepend-electron.js' )
@@ -92,10 +96,18 @@ export class ElectronInterceptor implements Interceptor {
9296 callFrameId
9397 } ) ;
9498
99+ if ( injectionResult . exceptionDetails ) {
100+ const exception = injectionResult . exceptionDetails as any ;
101+
102+ addBreadcrumb ( "Evaluate error" , {
103+ message : exception && exception . description ,
104+ data : injectionResult . exceptionDetails
105+ } ) ;
106+
107+ throw new Error ( "Failed to inject into Electron app" ) ;
108+ }
109+
95110 debugClient . Debugger . resume ( ) ;
96- debugClient . once ( 'disconnect' , ( ) => {
97- _ . remove ( this . debugClients [ proxyPort ] , c => c === debugClient ) ;
98- } ) ;
99111 }
100112
101113 async deactivate ( proxyPort : number | string ) : Promise < void > {
0 commit comments