Skip to content

[Bug] NDE replaying nested promises #1744

@antmendoza

Description

@antmendoza

What are you really trying to do?

Describe the bug

The following code throws an NDE during replay



    await Promise.all(
        [1, 3].map(async (offset) => {
            await Promise.all(
                ["a", "b", "c", "d", "e"].map(async (c) => {

                    console.log(`sleepRandomLocal start ${offset} ${c}`);


                    printActivities();
                    //schedule local activity
                    await sleepRandomLocal(1, 100, `${offset} ${c}`);
                    

                    console.log(`sleepRandom start ${offset} ${c}`);
                    printActivities();
                    //schedule activity
                    await sleepRandom(offset * 1000, offset * 1000, `${offset} ${c}`);
                })
            );

            console.log(`greet start ${offset}`);
            printActivities();
            //schedule activity
            await greet(offset.toString());
        })
    );


    printActivities();

    // Throw an error to force replay
    throw new Error("Something went wrong");

2025-07-15T08:54:54.526968Z  WARN temporal_sdk_core::worker::workflow: Failing workflow task run_id=01980d4b-3cd8-7271-abfb-0c98f28d3e91 failure=Failure { failure: Some(Failure { message: "[TMPRL1100] Nondeterminism error: No command scheduled for event HistoryEvent(id: 38, ActivityTaskScheduled)", source: "", stack_trace: "", encoded_attributes: None, cause: None, failure_info: 
Some(ApplicationFailureInfo(ApplicationFailureInfo { r#type: "", non_retryable: false, details: None, next_retry_delay: None, category: Unspecified })) }), force_cause: NonDeterministicError }

I added a log to the interceptor and activities seems to be scheduled in the same order (considering only activity type)

Runtime

sleepRandomLocal-1 a, sleepRandomLocal-1 b, sleepRandomLocal-1 c, sleepRandomLocal-1 d, sleepRandomLocal-1 e, sleepRandomLocal-3 a, sleepRandomLocal-3 b, sleepRandomLocal-3 c, sleepRandomLocal-3 d, sleepRandomLocal-3 e, sleepRandom-1 c, sleepRandom-1 a, sleepRandom-3 e, sleepRandom-3 d, sleepRandom-1 b, sleepRandom-3 a, sleepRandom-1 e, sleepRandom-3 c, sleepRandom-3 b, sleepRandom-1 d, greet-undefined, greet-undefined

Replay

sleepRandomLocal-1 a, sleepRandomLocal-1 b, sleepRandomLocal-1 c, sleepRandomLocal-1 d, sleepRandomLocal-1 e, sleepRandomLocal-3 a, sleepRandomLocal-3 b, sleepRandomLocal-3 c, sleepRandomLocal-3 d, sleepRandomLocal-3 e, sleepRandom-1 a, sleepRandom-1 b, sleepRandom-1 c, sleepRandom-1 d, sleepRandom-1 e, sleepRandom-3 a, sleepRandom-3 b, sleepRandom-3 c, sleepRandom-3 d

Minimal Reproduction

here is the code shared by the customer to reproduce the issue:

Archive.zip

Environment/Versions

version 1.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions