Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deadlock when thorw 'EtcdInvalidAuthTokenError' #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
16 changes: 9 additions & 7 deletions src/connection-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
IDefaultPolicyContext,
IPolicy,
isBrokenCircuitError,
Policy,
Policy
} 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 @@ -318,11 +318,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 @@ -331,6 +326,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