@@ -6,9 +6,9 @@ import * as Express from 'express';
66import { GraphQLScalarType } from 'graphql' ;
77
88import { HtkConfig } from './config' ;
9- import { reportError } from './error-tracking' ;
9+ import { reportError , addBreadcrumb } from './error-tracking' ;
1010import { buildInterceptors , Interceptor } from './interceptors' ;
11- import { ALLOWED_ORIGINS } from './util' ;
11+ import { ALLOWED_ORIGINS , delay } from './util' ;
1212
1313const packageJson = require ( '../package.json' ) ;
1414
@@ -69,11 +69,25 @@ const buildResolvers = (
6969 activateInterceptor : async ( __ : void , args : _ . Dictionary < any > ) => {
7070 const { id, proxyPort, options } = args ;
7171
72+ addBreadcrumb ( `Activating ${ id } ` , { category : 'interceptor' , data : { id, options } } ) ;
73+
7274 const interceptor = interceptors [ id ] ;
7375 if ( ! interceptor ) throw new Error ( `Unknown interceptor ${ id } ` ) ;
7476
75- await interceptor . activate ( proxyPort , options ) ;
76- return interceptor . isActive ( proxyPort ) ;
77+ await Promise . race ( [
78+ interceptor . activate ( proxyPort , options ) ,
79+ delay ( 30000 ) // After 30s, we don't stop activating, but we do report failure
80+ ] ) ;
81+
82+ const isActive = interceptor . isActive ( proxyPort ) ;
83+
84+ if ( isActive ) {
85+ addBreadcrumb ( `Successfully activated ${ id } ` , { category : 'interceptor' } ) ;
86+ } else {
87+ reportError ( new Error ( `Failed to activate ${ id } ` ) ) ;
88+ }
89+
90+ return isActive ;
7791 } ,
7892 deactivateInterceptor : async ( __ : void , args : _ . Dictionary < any > ) => {
7993 const { id, proxyPort, options } = args ;
0 commit comments