#5030·hatchet

[BUG] TS SDK: runManyNoWait inside a task makes the next spawn reuse a child index

Author: vipulpandey7860Created Sep 24, 2026Updated Sep 24, 2026

Describe the issue Inside a task, calling runManyNoWait (or runMany) and then spawning again, for example with runNoWait, gives the next spawn the same child index as the batch's first child. The engine returns that existing child instead of creating a new run. So the second spawn is silently dropped, and awaiting its output never resolves.

runManyNoWait increments the parent run context's childIndex before it reads it (declaration.ts L528–L533). #3561 fixed the same ordering in runNoWait in 1.20.1. It didn't touch runManyNoWait, which #3421 had added shortly before.

Environment

  • SDK: TypeScript 1.33.0 and 1.33.1 (still on main)
  • Engine: self-hosted v0.109.3; also reproduced on the embedded engine

Expected behavior Every spawn gets its own child index, so the run after the batch is created.

Code to Reproduce, Logs, or Screenshots

typescript
const child = hatchet.task({ name: 'child', fn: async (i: { tag: string }) => ({ tag: i.tag }) });

const parent = hatchet.task({
  name: 'parent',
  fn: async () => {
    await child.runManyNoWait([{ input: { tag: 'many-0' } }]); // gets childIndex 1, should be 0
    const single = await child.runNoWait({ tag: 'after-many' }); // gets childIndex 1 as well
    return single.output; // never resolves: no 'after-many' run is created
  },
});

Additional context The fix mirrors #3561: snapshot childIndex before incrementChildIndex(runs.length). I have it ready, with a bulk-then-single case added to the child_index e2e example. The case fails before the fix and passes after it. I'd like to take this on.


AI Disclosure
  • I acknowledge that an LLM was used in the creation of this Issue, in accordance with Hatchet's AI_POLICY.md.

  • Details: Claude Code traced a dropped task in our app to this line, wrote the reproduction and the e2e case, and drafted this issue. I reviewed and edited it.