Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/connection-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import {
IDefaultPolicyContext,
IPolicy,
isBrokenCircuitError,
Policy
retry,
} from 'cockatiel';
import {
castGrpcError,
ClientClosedError,
ClientRuntimeError,
EtcdInvalidAuthTokenError,
isRecoverableError,
isRecoverableError
} from './errors';
import { IOptions } from './options';
import { CallContext, ICallable, Services } from './rpc';
Expand Down Expand Up @@ -323,11 +324,6 @@ export class ConnectionPool implements ICallable<Host> {
try {
return await runServiceCall(client, metadata, resolvedOpts, method, payload);
} catch (err) {
if (err instanceof EtcdInvalidAuthTokenError) {
this.authenticator.invalidateMetadata();
return this.exec(serviceName, method, payload, options);
}

lastError = err;
throw err;
}
Expand All @@ -336,6 +332,13 @@ export class ConnectionPool implements ICallable<Host> {
),
);
} catch (e) {

// Tf auth token error, clear metadata and retry
if (e instanceof EtcdInvalidAuthTokenError) {
this.authenticator.invalidateMetadata();
return this.exec(serviceName, method, payload, options);
}

// If we ran into an error that caused the a circuit to open, but we had
// an error before that happened, throw the original error rather than
// the broken circuit error.
Expand Down