v3: Use global setTimeout to ensure cross-runtime support

This commit is contained in:
Eric Allam
2024-06-24 19:49:22 +01:00
parent 4acfb8f4bb
commit ecef199660
2 changed files with 6 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---
Use global setTimeout to ensure cross-runtime support
+1 -2
View File
@@ -8,7 +8,6 @@ import {
RetrieveRunResponse, RetrieveRunResponse,
apiClientManager, apiClientManager,
} from "@trigger.dev/core/v3"; } from "@trigger.dev/core/v3";
import { setTimeout } from "timers/promises";
import { Prettify, RunHandle, apiClientMissingError } from "./shared"; import { Prettify, RunHandle, apiClientMissingError } from "./shared";
export type RetrieveRunResult<TOutput> = Prettify< export type RetrieveRunResult<TOutput> = Prettify<
@@ -98,6 +97,6 @@ async function poll<TRunHandle extends RunHandle<any> | string>(
return run; return run;
} }
await setTimeout(Math.max(options?.pollIntervalMs ?? 5000, 1000)); await new Promise((resolve) => setTimeout(resolve, options?.pollIntervalMs ?? 1000));
} }
} }