@monokle/synchronizer
Advanced tools
Comparing version 0.12.4 to 0.12.5
@@ -13,2 +13,2 @@ export declare type OriginConfig = { | ||
}; | ||
export declare function fetchOriginConfig(origin: string): Promise<OriginConfig>; | ||
export declare function fetchOriginConfig(origin: string, timeout?: number): Promise<OriginConfig>; |
@@ -19,3 +19,3 @@ "use strict"; | ||
let originConfigCache = undefined; | ||
function fetchOriginConfig(origin) { | ||
function fetchOriginConfig(origin, timeout = 30 * 1000) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -30,3 +30,3 @@ if (originConfigCache) { | ||
const configUrl = normalize(`${origin}/config.js`); | ||
const response = yield (0, node_fetch_1.default)(configUrl); | ||
const response = yield (0, node_fetch_1.default)(configUrl, { timeout }); | ||
if (!response.ok) { | ||
@@ -33,0 +33,0 @@ throw new Error(`Failed to fetch config from ${configUrl} with status ${response.status}: ${response.statusText}`); |
@@ -13,2 +13,2 @@ export declare type OriginConfig = { | ||
}; | ||
export declare function fetchOriginConfig(origin: string): Promise<OriginConfig>; | ||
export declare function fetchOriginConfig(origin: string, timeout?: number): Promise<OriginConfig>; |
import normalizeUrl from 'normalize-url'; | ||
import fetch from 'node-fetch'; | ||
let originConfigCache = undefined; | ||
export async function fetchOriginConfig(origin) { | ||
export async function fetchOriginConfig(origin, timeout = 30 * 1000) { | ||
if (originConfigCache) { | ||
@@ -13,3 +13,3 @@ // Use recently fetched config if from same origin and it's less than 5 minutes old. | ||
const configUrl = normalize(`${origin}/config.js`); | ||
const response = await fetch(configUrl); | ||
const response = await fetch(configUrl, { timeout }); | ||
if (!response.ok) { | ||
@@ -16,0 +16,0 @@ throw new Error(`Failed to fetch config from ${configUrl} with status ${response.status}: ${response.statusText}`); |
{ | ||
"name": "@monokle/synchronizer", | ||
"version": "0.12.4", | ||
"version": "0.12.5", | ||
"description": "Monokle Cloud synchronizer", | ||
@@ -5,0 +5,0 @@ "author": "Kubeshop", |
214207