@@ -17,17 +17,17 @@ import { timeout } from './common/async';
17
17
import { MetricsReporter , getConnectMetricsInterceptor , getGrpcMetricsInterceptor } from './metrics' ;
18
18
19
19
function isTelemetryEnabled ( ) : boolean {
20
- const TELEMETRY_CONFIG_ID = 'telemetry' ;
21
- const TELEMETRY_CONFIG_ENABLED_ID = 'enableTelemetry' ;
20
+ const TELEMETRY_CONFIG_ID = 'telemetry' ;
21
+ const TELEMETRY_CONFIG_ENABLED_ID = 'enableTelemetry' ;
22
22
23
- if ( vscode . env . isTelemetryEnabled !== undefined ) {
24
- return vscode . env . isTelemetryEnabled ? true : false ;
25
- }
23
+ if ( vscode . env . isTelemetryEnabled !== undefined ) {
24
+ return vscode . env . isTelemetryEnabled ? true : false ;
25
+ }
26
26
27
- // We use the old and new setting to determine the telemetry level as we must respect both
28
- const config = vscode . workspace . getConfiguration ( TELEMETRY_CONFIG_ID ) ;
29
- const enabled = config . get < boolean > ( TELEMETRY_CONFIG_ENABLED_ID ) ;
30
- return ! ! enabled ;
27
+ // We use the old and new setting to determine the telemetry level as we must respect both
28
+ const config = vscode . workspace . getConfiguration ( TELEMETRY_CONFIG_ID ) ;
29
+ const enabled = config . get < boolean > ( TELEMETRY_CONFIG_ENABLED_ID ) ;
30
+ return ! ! enabled ;
31
31
}
32
32
33
33
export class GitpodPublicApi extends Disposable {
@@ -119,26 +119,36 @@ export class GitpodPublicApi extends Disposable {
119
119
this . _streamWorkspaceStatus ( workspaceId ) ;
120
120
}
121
121
122
+ private _stopTimer : NodeJS . Timeout | undefined ;
122
123
private _streamWorkspaceStatus ( workspaceId : string ) {
123
124
const call = this . grpcWorkspaceClient . streamWorkspaceStatus ( { workspaceId } , this . grpcMetadata ) ;
124
125
call . on ( 'data' , ( res ) => {
125
126
this . _onWorkspaceStatusUpdate . fire ( res . result ! ) ;
126
127
} ) ;
127
128
call . on ( 'end' , async ( ) => {
128
- await timeout ( 2000 ) ;
129
+ clearTimeout ( this . _stopTimer ) ;
129
130
130
131
if ( this . isDisposed ) { return ; }
131
132
132
- this . logger . trace ( `streamWorkspaceStatus stream ended, retrying ...` ) ;
133
+ this . logger . trace ( `streamWorkspaceStatus stream ended` ) ;
134
+
135
+ await timeout ( 1000 ) ;
133
136
this . _streamWorkspaceStatus ( workspaceId ) ;
134
137
} ) ;
135
138
call . on ( 'error' , ( err ) => {
136
139
this . logger . trace ( `Error in streamWorkspaceStatus` , err ) ;
137
140
} ) ;
141
+
142
+ // force reconnect after 7m to avoid unexpected 10m reconnection (internal error)
143
+ this . _stopTimer = setTimeout ( ( ) => {
144
+ this . logger . trace ( `streamWorkspaceStatus forcing cancel after 7 minutes` ) ;
145
+ call . cancel ( ) ;
146
+ } , 7 * 60 * 1000 /* 7 min */ ) ;
138
147
}
139
148
140
149
public override dispose ( ) {
141
150
super . dispose ( ) ;
151
+ clearTimeout ( this . _stopTimer ) ;
142
152
this . metricsReporter . stopReporting ( ) ;
143
153
}
144
154
}
0 commit comments