From 80071beaacd4303bd5c7edb699d202861fd98b50 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 13 Jul 2018 19:38:35 +0200 Subject: Add assertion to make sure caller to fetchAsync isn't trying to set timeout in a context-specific way --- packages/utils/src/fetchAsync.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'packages/utils/src') diff --git a/packages/utils/src/fetchAsync.ts b/packages/utils/src/fetchAsync.ts index 8295ff5ec..6ae2ba1a4 100644 --- a/packages/utils/src/fetchAsync.ts +++ b/packages/utils/src/fetchAsync.ts @@ -6,6 +6,9 @@ export const fetchAsync = async ( options: RequestInit = {}, timeoutMs: number = 20000, ): Promise => { + if (options.signal || (options as any).timeout) { + throw new Error('Cannot call fetchAsync with options.signal or options.timeout. To set a timeout, please use the supplied "timeoutMs" parameter.'); + } let optionsWithAbortParam; if (!isNode) { const controller = new AbortController(); -- cgit