From 26446b765f2589613bc50dcdb7ba7cae23443df6 Mon Sep 17 00:00:00 2001 From: Casper Date: Tue, 2 Jan 2024 10:14:21 +0100 Subject: [PATCH] Limit the timeout in accordance with API specs --- src/Client.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index 1e17668..53cb335 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -14,7 +14,7 @@ import { } from './CreatomateError'; import { transformObjectKeys, transformCamelToSnakeCase, transformSnakeToCamelCase } from './utility'; -const CLIENT_VERSION = '1.0.5'; +const CLIENT_VERSION = '1.1.0'; export class Client { private readonly apiKey: string; @@ -34,7 +34,7 @@ export class Client { * Starts a new render and awaits its completion. * @param options Render options. * @param timeout Maximum time in seconds to wait for the render to complete. If the render is not finished within the - * specified time, a 'TimeoutError' is thrown. + * specified time, a 'TimeoutError' is thrown. The maximum timeout is 15 minutes (900 seconds). */ async render(options: RenderOptions, timeout = 900): Promise { const renders = await this.startRender(options); @@ -76,7 +76,7 @@ export class Client { return; } - if (performance.now() - startTime >= timeout * 1000) { + if (performance.now() - startTime >= Math.min(timeout, 900) * 1000) { reject(new TimeoutError()); return; }