Consider the example below:
const userPromise = context.step(async () => fetchUser());
const orderPromise = context.step(async () => fetchOrders());
const [user, orders] = await Promise.all([userPromise, orderPromise]);
The above example can produce non-deterministic behaviours because the SDK assigns each operation a number to track it in the checkpoint log. If two operations start at the same time, their numbers can be assigned in different orders on different runs. On replay, the SDK might match the wrong checkpoint to the wrong step.
The safe way to run things concurrently is to use parallel or map with the Durable Lambda SDK.
Top comments (0)