We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ea09dcd commit 58916c0Copy full SHA for 58916c0
1 file changed
packages/durabletask-js/src/utils/backoff.util.ts
@@ -213,7 +213,7 @@ export async function withTimeout<T>(
213
timeoutMs: number,
214
timeoutMessage = "Operation timed out",
215
): Promise<T> {
216
- let timeoutId: ReturnType<typeof setTimeout>;
+ let timeoutId: ReturnType<typeof setTimeout> | undefined;
217
218
const timeoutPromise = new Promise<never>((_, reject) => {
219
timeoutId = setTimeout(() => reject(new Error(timeoutMessage)), timeoutMs);
@@ -222,6 +222,8 @@ export async function withTimeout<T>(
222
try {
223
return await Promise.race([promise, timeoutPromise]);
224
} finally {
225
- clearTimeout(timeoutId!);
+ if (timeoutId !== undefined) {
226
+ clearTimeout(timeoutId);
227
+ }
228
}
229
0 commit comments