Skip to content

fix: signal completion only after task, with real exit status (#24) - #25

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/24-completion-after-task
Jun 3, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/24-completion-after-task

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Fixes #24.

Correction to the issue's root-cause hypothesis

The issue says spored's bootstrap creates /tmp/SPAWN_COMPLETE. I checked spawn's code: the bootstrap does NOT create it — it only watches it. The JSON {"status":"success"} the reporter saw is exactly what spored complete --status success writes, which is nf-spawn's own staging script (line 216), not spored's boot.

The actual bug

The staging script ran:

spored complete --status success 2>/dev/null || touch /tmp/SPAWN_COMPLETE

unconditionally — with set -uo pipefail (no set -e), the script never aborts on a failed/short-circuited task, so it always reached this line and signaled success. Result: spawn status --check-complete returned 0 (complete, success) moments after boot, regardless of the task's real state.

Fix

Capture the task's exit code and signal the real outcome as the genuine last step:

bash .command.sh 1>.command.out 2>.command.err
TASK_RC=0
echo "${TASK_RC}" > .exitcode
# ... sync outputs + .exitcode ...
if [ "${TASK_RC}" -eq 0 ]; then COMPLETE_STATUS=success; else COMPLETE_STATUS=failed; fi
spored complete --status "${COMPLETE_STATUS}" 2>/dev/null || touch /tmp/SPAWN_COMPLETE

spored complete --status failed makes --check-complete return 1, so Nextflow sees a genuine pass/fail instead of a spurious early success.

Test

Spock spec asserts the status is derived from TASK_RC (not hard-coded success), the unconditional --status success is gone, and the signal is strictly the last step. ./gradlew test green (8 tests).

The staging script ran 'spored complete --status success' UNCONDITIONALLY
(2>/dev/null, no set -e), so a 'success' completion was signaled regardless
of whether the task succeeded, failed, or had meaningfully run — tasks
appeared complete (and successful) moments after boot, and
'spawn status --check-complete' returned 0 immediately.

Correction to the issue's hypothesis: spawn's bootstrap does NOT create
/tmp/SPAWN_COMPLETE (it only watches it). The JSON {"status":"success"}
the reporter saw is exactly what THIS line wrote — the bug was here, not in
spored's boot sequence.

Fix: capture the task exit code (TASK_RC) and signal success/failed
accordingly, as the genuine last step after outputs sync. spored complete
--status failed makes --check-complete return 1, so Nextflow sees a real
pass/fail instead of a spurious early success.

Spock spec asserts status is derived from TASK_RC (not hard-coded success),
the unconditional 'spored complete --status success' is gone, and the
signal is strictly last.

Fixes #24
@scttfrdmn
scttfrdmn merged commit b83e98e into main Jun 3, 2026
1 check passed
@scttfrdmn
scttfrdmn deleted the fix/24-completion-after-task branch June 3, 2026 23:38
@scttfrdmn scttfrdmn mentioned this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SPAWN_COMPLETE created by spored bootstrap, not task completion — tasks appear complete before running

1 participant