1- import { logger } from "@coder/logger" ;
1+ import { logger , field } from "@coder/logger" ;
22import { NotificationService , INotificationHandle , INotificationService , Severity } from "./fill/notification" ;
33
44interface IRetryItem {
@@ -105,7 +105,7 @@ export class Retry {
105105 /**
106106 * Retry a service.
107107 */
108- public run ( name : string ) : void {
108+ public run ( name : string , error ?: Error ) : void {
109109 if ( ! this . items . has ( name ) ) {
110110 throw new Error ( `"${ name } " is not registered` ) ;
111111 }
@@ -117,15 +117,15 @@ export class Retry {
117117
118118 item . running = true ;
119119 // This timeout is for the case when the connection drops; this allows time
120- // for the Wush service to come in and block everything because some other
120+ // for the socket service to come in and block everything because some other
121121 // services might make it here first and try to restart, which will fail.
122122 setTimeout ( ( ) => {
123123 if ( this . blocked && this . blocked !== name ) {
124124 return ;
125125 }
126126
127127 if ( ! item . count || item . count < this . maxImmediateRetries ) {
128- return this . runItem ( name , item ) ;
128+ return this . runItem ( name , item , error ) ;
129129 }
130130
131131 if ( ! item . delay ) {
@@ -137,10 +137,10 @@ export class Retry {
137137 }
138138 }
139139
140- logger . info ( `Retrying ${ name . toLowerCase ( ) } in ${ item . delay } s` ) ;
140+ logger . info ( `Retrying ${ name . toLowerCase ( ) } in ${ item . delay } s` , error && field ( "error" , error . message ) ) ;
141141 const itemDelayMs = item . delay * 1000 ;
142142 item . end = Date . now ( ) + itemDelayMs ;
143- item . timeout = setTimeout ( ( ) => this . runItem ( name , item ) , itemDelayMs ) ;
143+ item . timeout = setTimeout ( ( ) => this . runItem ( name , item , error ) , itemDelayMs ) ;
144144
145145 this . updateNotification ( ) ;
146146 } , this . waitDelay ) ;
@@ -165,7 +165,7 @@ export class Retry {
165165 /**
166166 * Run an item.
167167 */
168- private runItem ( name : string , item : IRetryItem ) : void {
168+ private runItem ( name : string , item : IRetryItem , error ?: Error ) : void {
169169 if ( ! item . count ) {
170170 item . count = 1 ;
171171 } else {
@@ -175,7 +175,7 @@ export class Retry {
175175 const retryCountText = item . count <= this . maxImmediateRetries
176176 ? `[${ item . count } /${ this . maxImmediateRetries } ]`
177177 : `[${ item . count } ]` ;
178- logger . info ( `Trying ${ name . toLowerCase ( ) } ${ retryCountText } ...` ) ;
178+ logger . info ( `Starting ${ name . toLowerCase ( ) } ${ retryCountText } ...` , error && field ( "error" , error . message ) ) ;
179179
180180 const endItem = ( ) : void => {
181181 this . stopItem ( item ) ;
0 commit comments