@@ -1865,10 +1865,11 @@ export namespace Telemetry {
18651865 // one flush interval instead of at the next process start.
18661866 let identityStamp = ""
18671867 // altimate_change — a resolution that failed while a credential exists (backend down, timeout)
1868- // must be tried again, but not on every 5 s flush: the stamp is reset so the next flush after
1869- // this time re-resolves.
1868+ // is tried again at the first flush after this time, not on every 5 s flush. The stamp of the
1869+ // failed credential is kept, so a different credential appearing in the meantime is noticed at
1870+ // once by the stamp comparison; the backoff only throttles retries of the unchanged one.
18701871 const IDENTITY_RETRY_MS = 60_000
1871- let identityRetryAt = 0
1872+ let identityRetryAt = 0 // 0: no retry pending
18721873 let machineId = ""
18731874 let sessionId = ""
18741875 let projectId = ""
@@ -2141,16 +2142,14 @@ export namespace Telemetry {
21412142 function resolveIdentity ( opts : { refresh ?: boolean } = { } ) : Promise < void > {
21422143 const generation = ++ identityGeneration
21432144 identityStamp = TelemetryIdentity . credentialStamp ( )
2145+ identityRetryAt = 0
21442146 return TelemetryIdentity . resolve ( opts )
21452147 . then ( async ( resolved ) => {
21462148 if ( generation !== identityGeneration ) return
21472149 identity = resolved
21482150 if ( resolved === undefined && ( await TelemetryIdentity . hasCredential ( ) ) ) {
21492151 // Signed in but unresolved: a transient failure. Retry at a later flush.
2150- if ( generation === identityGeneration ) {
2151- identityStamp = ""
2152- identityRetryAt = Date . now ( ) + IDENTITY_RETRY_MS
2153- }
2152+ if ( generation === identityGeneration ) identityRetryAt = Date . now ( ) + IDENTITY_RETRY_MS
21542153 }
21552154 } )
21562155 . catch ( ( ) => { } )
@@ -2170,9 +2169,9 @@ export namespace Telemetry {
21702169 return identity
21712170 }
21722171
2173- /** Test seam: end the retry backoff so the next flush re-resolves. */
2172+ /** Test seam: end a pending retry backoff so the next flush re-resolves. */
21742173 export function retryIdentityNowForTest ( ) {
2175- identityRetryAt = 0
2174+ if ( identityRetryAt !== 0 ) identityRetryAt = 1
21762175 }
21772176 // altimate_change end
21782177
@@ -2372,9 +2371,10 @@ export namespace Telemetry {
23722371 // change on disk and re-resolve (cheap: two stats, and the cache answers unless the key changed).
23732372 const who = identity
23742373 const mid = machineId
2375- if ( enabled && Date . now ( ) >= identityRetryAt ) {
2374+ if ( enabled ) {
23762375 const stamp = TelemetryIdentity . credentialStamp ( )
2377- if ( stamp !== identityStamp ) {
2376+ const retryDue = identityRetryAt !== 0 && Date . now ( ) >= identityRetryAt
2377+ if ( stamp !== identityStamp || retryDue ) {
23782378 identity = undefined
23792379 void resolveIdentity ( )
23802380 }
0 commit comments