Skip to content

Commit bed96e5

Browse files
Replace setTimeout with setImmediate (#560)
1 parent 2cd1da5 commit bed96e5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/restate-sdk/src/promises.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
} from "./types/errors.js";
2626
import { CompletablePromise } from "./utils/completable_promise.js";
2727
import type { ContextImpl, RunClosuresTracker } from "./context_impl.js";
28-
import { setTimeout } from "node:timers/promises";
28+
import { setImmediate } from "node:timers/promises";
2929
import type { InputPump, OutputPump } from "./io.js";
3030
import type { Duration } from "@restatedev/restate-sdk-core";
3131

@@ -415,7 +415,7 @@ export class PromisesExecutor {
415415
// The reason for this setTimeout is that we need to enqueue the polling after
416416
// we eventually resolve some promises. This is especially crucial for RestateCombinatorPromise
417417
// as it flips the completed state using .finally() on the combinator.
418-
return setTimeout().then(async () => {
418+
return setImmediate().then(async () => {
419419
try {
420420
// Invoke do progress on the vm
421421
const handles = restatePromise.uncompletedLeaves();
@@ -442,7 +442,7 @@ export class PromisesExecutor {
442442
// We need to execute a run closure
443443
this.runClosuresTracker.executeRun(doProgressResult.ExecuteRun);
444444
// Let the run context switch, then come back to this flow.
445-
await setTimeout();
445+
await setImmediate();
446446
}
447447

448448
// Recursion

0 commit comments

Comments
 (0)