Skip to content

Commit

Permalink
Increase default timeout of api instances except for validator duties (
Browse files Browse the repository at this point in the history
…#3684)

* Increase default timeout of api instances except for validator duties

* Set default timeout to 60 seconds for simplicity

Co-authored-by: Lion - dapplion <35266934+dapplion@users.noreply.github.com>
  • Loading branch information
g11tech and dapplion authored Feb 1, 2022
1 parent 52032f8 commit c9b5350
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/api/src/client/utils/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export class HttpClient implements IHttpClient {
*/
constructor(opts: HttpClientOptions) {
this.baseUrl = opts.baseUrl;
this.timeoutMs = opts.timeoutMs ?? 12000;
// A higher default timeout, validator will sets its own shorter timeoutMs
this.timeoutMs = opts.timeoutMs ?? 60_000;
this.getAbortSignal = opts.getAbortSignal;
this.fetch = opts.fetch ?? fetch;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/validator/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class Validator {
typeof opts.api === "string"
? getClient(config, {
baseUrl: opts.api,
// Validator would need the beacon to respond within the slot
timeoutMs: config.SECONDS_PER_SLOT * 1000,
getAbortSignal: this.getAbortSignal,
})
Expand Down Expand Up @@ -88,7 +89,9 @@ export class Validator {
const {config} = opts.dbOps;
const api =
typeof opts.api === "string"
? getClient(config, {baseUrl: opts.api, timeoutMs: 12000, getAbortSignal: () => signal})
? // This new api instance can make do with default timeout as a faster timeout is
// not necessary since this instance won't be used for validator duties
getClient(config, {baseUrl: opts.api, getAbortSignal: () => signal})
: opts.api;

const genesis = await waitForGenesis(api, opts.logger, signal);
Expand Down

0 comments on commit c9b5350

Please sign in to comment.