@@ -166,6 +166,7 @@ export class CrashMonitoring {
166166 * {@link CrashChecker} listens for these.
167167 */
168168class Heartbeat {
169+ private didEmitFailure : boolean = false
169170 private isRunning : boolean = false
170171 private intervalRef : NodeJS . Timer | undefined
171172 constructor (
@@ -175,8 +176,6 @@ class Heartbeat {
175176 ) { }
176177
177178 public async start ( ) {
178- this . isRunning = true
179-
180179 // heartbeat 2 times per check
181180 const heartbeatInterval = this . checkInterval / 2
182181
@@ -188,19 +187,20 @@ class Heartbeat {
188187 try {
189188 await this . state . sendHeartbeat ( )
190189 } catch ( e ) {
191- emitFailure ( { functionName : 'sendHeartbeat' , error : e } )
192-
193- // Since there was an error we want to stop crash monitoring since it is pointless.
194- // We will need to monitor telemetry to see if we can determine widespread issues.
195- // Make sure it is signaled as a graceful shutdown to reduce noise of crashed extensions.
196- await this . stop ( )
190+ // only emit a failure once so we do not spam telemetry on repeated errors
191+ if ( ! this . didEmitFailure ) {
192+ this . didEmitFailure = true
193+ emitFailure ( { functionName : 'sendHeartbeat' , error : e } )
194+ }
197195
198196 // During development we are fine with impacting extension execution, so throw
199197 if ( this . isDevMode ) {
200198 throw e
201199 }
202200 }
203201 } , heartbeatInterval )
202+
203+ this . isRunning = true
204204 }
205205
206206 public async stop ( ) {
@@ -491,7 +491,7 @@ export class FileSystemState {
491491 // Clean up the running extension file since it is no longer exists
492492 const dir = await this . runningExtsDir ( )
493493 // Use force since another checker may have already removed this file before this is ran
494- await withFailCtx ( 'deleteStaleRunningFile' , ( ) => fs . delete ( path . join ( dir , extId ) , { force : true } ) )
494+ await withFailCtx ( 'deleteStaleRunningFile' , ( ) => fs . delete ( path . join ( dir , extId ) ) )
495495 }
496496
497497 // ------------------ State data ------------------
0 commit comments