Repository navigation
Description
What
Four exec-based tests run a generated task script and then read the record it wrote at the hardcoded absolute path /tmp/spawn-completion.json:
pkg/taskproto/wrapper_test.go:984,:1088,:1324(viaGenerateWrapper)pkg/taskpool/exec_test.go:67— runs the pooled script for tasknf-fail(exit 17), which writes the same path
go test ./... runs different packages in parallel, so pkg/taskproto and pkg/taskpool write and read one shared file. Whichever script finishes last decides what the other package's test reads.
Observed
Same commit, same machine, no code change between the two batches — only test-cache state differs:
BRANCH: full ./... x3 -> pass, pass, pass
MAIN: full ./... x3 -> FAIL, FAIL, FAIL
and earlier, the exact inverse. The failure is TestGenerateWrapper_RunIDKeepsCompletionJSONValid reading the other package's record:
wrapper_test.go:1339: run_id = "65006d28-a080-4096-aaf3-de66bf7fd13e", want "11111111-2222-3333-4444-555555555555"
record: { "task_id": "nf-fail", "exit_code": 17, "state": "failed", "retry_class": "app_error" }
nf-fail appears nowhere in pkg/taskproto — it is pkg/taskpool/exec_test.go's task id, which is what identifies this as cross-package rather than a stale leftover.
Narrowing to just the two packages (go test ./pkg/taskproto/ ./pkg/taskpool/) passes 6/6 in both directions — the race needs the full suite's wider parallelism to lose reliably.
Why CI hasn't caught it
CI is currently green and has been. It runs on Linux, cold-cache, with -coverprofile, which happens to order these differently. That makes this a latent landmine rather than an active breakage: it will bite on an unrelated PR, and it reads as "your change broke the task wrapper" when it did not. It cost exactly that misdiagnosis once already (spawn#632's branch, where the failure appeared on the branch and not on main, then reversed).
Note on the obvious fix
/tmp itself is load-bearing in production and should NOT be parameterized by an env var: spored shares the host /tmp (spawn#66, PrivateTmp hid /tmp/SPAWN_COMPLETE and silently killed auto-shutdown), and the terminal-flush hook (#632) uses /tmp/spawn-completion.json's existence as its "the wrapper already wrote the real record" interlock. A runtime override would let the wrapper and the independently-generated flush script disagree about the path, which would make the hook overwrite completed records — strictly worse than this flake.
A generate-time directory (default /tmp, set only by tests, so the wrapper and flush script in one launch always share one value) avoids that. A per-process package-level var works because each package's tests are a separate binary.
Found while fixing #632.
Activity
chore(release): v0.116.0