Skip to content
Draft
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
13 changes: 13 additions & 0 deletions packages/transporter/src/createTransporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
} from '.';
import { retryableRequest } from './concerns/retryableRequest';

// setTimeout is using uint32, so this is the maximum in ms and 5x is the max timeout multiplier
const MAX_TIMEOUT_VALUE = 0x7fffffff / 5000;

export function createTransporter(options: TransporterOptions): Transporter {
const {
hostsCache,
Expand All @@ -23,6 +26,16 @@ export function createTransporter(options: TransporterOptions): Transporter {
headers,
} = options;

if (
timeouts.connect > MAX_TIMEOUT_VALUE ||
timeouts.read > MAX_TIMEOUT_VALUE ||
timeouts.write > MAX_TIMEOUT_VALUE
) {
throw new Error(
`Timeout values can be no higher than setTimeout accepts (in seconds), ${MAX_TIMEOUT_VALUE}`
);
}

const transporter: Transporter = {
hostsCache,
logger,
Expand Down