fix(FN-4122): use unique tmp filename for task.json atomic writes

Two TaskStore instances writing to the same task concurrently raced on a
shared task.json.tmp filename: one writer's rename consumed the tmp file,
the other ENOENTed. withTaskLock only serializes within a single store
instance, so cross-process writers (engine + dashboard server) were
unprotected.

Each write now uses task.json.<pid>.<uuid>.tmp and cleans up its own tmp
on rename failure. Adds a regression test that drives 40 concurrent
same-task updates across 4 TaskStore instances.

Fixes FN-4122, FN-4123, FN-4148.
This commit is contained in:
gsxdsm
2026-05-12 09:41:43 -07:00
parent 6709703411
commit 67c680c8d5
3 changed files with 44 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@runfusion/fusion": patch
---
Fix `ENOENT: ... rename 'task.json.tmp' -> 'task.json'` failures when two TaskStore instances (e.g. engine + dashboard server) write to the same task concurrently. The shared `task.json.tmp` filename caused one writer's `rename` to consume the tmp file and the other's to ENOENT. Each write now uses a unique tmp filename (`task.json.<pid>.<uuid>.tmp`) and cleans up its own tmp on rename failure.