Skip to content

Commit

Permalink
Limit the timeout in accordance with API specs
Browse files Browse the repository at this point in the history
  • Loading branch information
casperkloppenburg committed Jan 2, 2024
1 parent 6ad3912 commit 26446b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Render[]> {
const renders = await this.startRender(options);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 26446b7

Please sign in to comment.