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

feat: more information for exceed timeout error #839

Merged
merged 11 commits into from
Jun 2, 2020
7 changes: 5 additions & 2 deletions src/normalCalls/retries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ export function retryable(
let timeoutId: ReturnType<typeof setTimeout> | null;
let now = new Date();
let deadline: number;
const startTime = now.getTime();
if (retry.backoffSettings.totalTimeoutMillis) {
deadline = now.getTime() + retry.backoffSettings.totalTimeoutMillis;
deadline = startTime + retry.backoffSettings.totalTimeoutMillis;
}
let retries = 0;
const maxRetries = retry.backoffSettings.maxRetries!;
Expand All @@ -80,8 +81,10 @@ export function retryable(
function repeat() {
timeoutId = null;
if (deadline && now.getTime() >= deadline) {
const timeCost = now.getTime() - startTime;
const funcName = func.name;
const error = new GoogleError(
'Retry total timeout exceeded before any response was received'
`${funcName} takes ${timeCost} milliseconds which exceeds retry total timeout ${retry.backoffSettings.totalTimeoutMillis} milliseconds before any response was received. The retry settings is ${retry.backoffSettings}.`
);
error.code = Status.DEADLINE_EXCEEDED;
callback(error);
Expand Down