@@ -25,6 +25,7 @@ export class FailedPodHandler {
2525
2626 private readonly informer : Informer < V1Pod > ;
2727 private readonly reconnectIntervalMs : number ;
28+ private reconnecting = false ;
2829
2930 // Metrics
3031 private readonly register : Registry ;
@@ -250,21 +251,48 @@ export class FailedPodHandler {
250251 }
251252
252253 private makeOnError ( informerName : string ) {
253- return ( ) => this . onError ( informerName ) ;
254+ return ( err ?: unknown ) => this . onError ( informerName , err ) ;
254255 }
255256
256- private async onError ( informerName : string ) {
257+ private async onError ( informerName : string , err ?: unknown ) {
257258 if ( ! this . isRunning ) {
258259 this . logger . warn ( "onError: informer not running" ) ;
259260 return ;
260261 }
261262
262- this . logger . error ( "error event fired" , { informerName } ) ;
263- this . informerEventsTotal . inc ( { namespace : this . namespace , verb : "error" } ) ;
263+ // Guard against multiple simultaneous reconnections
264+ if ( this . reconnecting ) {
265+ this . logger . debug ( "onError: reconnection already in progress, skipping" , {
266+ informerName,
267+ } ) ;
268+ return ;
269+ }
264270
265- // Reconnect on errors
266- await setTimeout ( this . reconnectIntervalMs ) ;
267- await this . informer . start ( ) ;
271+ this . reconnecting = true ;
272+
273+ try {
274+ const error = err instanceof Error ? err : undefined ;
275+ this . logger . error ( "error event fired" , {
276+ informerName,
277+ error : error ?. message ,
278+ errorType : error ?. name ,
279+ } ) ;
280+ this . informerEventsTotal . inc ( { namespace : this . namespace , verb : "error" } ) ;
281+
282+ // Reconnect on errors
283+ await setTimeout ( this . reconnectIntervalMs ) ;
284+ await this . informer . start ( ) ;
285+ } catch ( handlerError ) {
286+ const error = handlerError instanceof Error ? handlerError : undefined ;
287+ this . logger . error ( "onError: reconnection attempt failed" , {
288+ informerName,
289+ error : error ?. message ,
290+ errorType : error ?. name ,
291+ errorStack : error ?. stack ,
292+ } ) ;
293+ } finally {
294+ this . reconnecting = false ;
295+ }
268296 }
269297
270298 private makeOnConnect ( informerName : string ) {
0 commit comments