Skip to content

Commit

Permalink
feat(data): add a default 10s timeout when fetching data from gateway…
Browse files Browse the repository at this point in the history
…s PE-4212

The Axios default is no timeout. This is especially bad when fetching data for
bundle processing since it can block the unbundling queue. This adds an initially
conservative 10 second timeout for fetching data from other gateways.
  • Loading branch information
djwhitt committed Jul 21, 2023
1 parent f6b0b54 commit 862f495
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/data/gateway-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@ import winston from 'winston';

import { ContiguousData, ContiguousDataSource } from '../types.js';

const DEFAULT_REQUEST_TIMEOUT_MS = 10000;

export class GatewayDataSource implements ContiguousDataSource {
private log: winston.Logger;
private trustedGatewayAxios;

constructor({
log,
trustedGatewayUrl,
requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT_MS,
}: {
log: winston.Logger;
trustedGatewayUrl: string;
requestTimeoutMs?: number;
}) {
this.log = log.child({ class: 'GatewayDataSource' });
this.trustedGatewayAxios = axios.create({
baseURL: trustedGatewayUrl,
timeout: requestTimeoutMs,
});
}

Expand Down

0 comments on commit 862f495

Please sign in to comment.