Skip to content

Do not hang job-level instrumentation in only_job mode - #4858

Merged
plengauer merged 2 commits into
mainfrom
claude/exciting-fermat-k78xlf
Dec 4, 2026
Merged

plengauer merged 2 commits into
mainfrom
claude/exciting-fermat-k78xlf

Conversation

@plengauer

Copy link
Copy Markdown
Owner

Problem

Job-level instrumentation hangs forever in its pre step when only_job: true is set (introduced in #4830). Observed in autopuppeteer, dafuq and bash-ai: the Pre Run …/instrument/job@bd10fab… step stays in_progress for hours (5 runs cancelled after 4–6 h), while the same version with only_job: false finishes the pre step in ~20 s.

Root cause

inject_and_init.sh starts the only_job daemon (nohup setsid bash -c '… while true; do sleep 1; done' &) as a background child of the script's shell. The script has bare wait calls (before "Resolve Trace Context", inside the trace context loop, and in "Waiting for background init jobs"), and a bare wait waits for all children, so it blocks on the daemon's endless loop.

Fix

Launch the daemon from a subshell, ( nohup setsid bash -c '…' &>/dev/null & ), so it is not a child of the script's shell and the bare waits ignore it. shutdown.sh finds it via only_job_pid in GITHUB_STATE, so nothing else changes.

Verification

  • bash -n passes.
  • Isolated reproduction: backgrounding the daemon and calling wait hangs until killed by timeout; with the subshell form wait returns immediately.
  • Not verified: the full action on a real runner. The logs of the stuck runs were never uploaded, so the cause is inferred from code, the only_job on/off comparison and the reproduction.

No VERSION bump included; the affected repos pin bd10fab # v5.68.0 and need a release containing this fix.


Generated by Claude Code

The only_job daemon was started as a background child of the init script, so the bare waits in the same script waited for its endless loop forever and the pre step never finished. Start it from a subshell so it is not a child of the script's shell.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WAy2NdEwyteCeJENENbBnE
@plengauer plengauer self-assigned this Dec 4, 2026
@plengauer
plengauer marked this pull request as ready for review December 4, 2026 08:16
@plengauer
plengauer requested a review from moflwi as a code owner December 4, 2026 08:16
@plengauer
plengauer enabled auto-merge (squash) December 4, 2026 08:16
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

✅⚠️MegaLinter analysis: Success with warnings

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ BASH shellcheck 1 0 0 3.23s
⚠️ BASH shfmt 1 1 0 0.01s
✅ COPYPASTE jscpd yes no no 0.92s
✅ REPOSITORY betterleaks yes no no 7.06s
✅ REPOSITORY checkov yes no no 10.64s
✅ REPOSITORY dustilock yes no no 5.58s
✅ REPOSITORY git_diff yes no no 0.18s
⚠️ REPOSITORY grype yes no 1 90.65s
✅ REPOSITORY kingfisher yes no no 7.32s
✅ REPOSITORY osv-scanner yes no no 14.33s
✅ REPOSITORY secretlint yes no no 2.03s
✅ REPOSITORY syft yes no no 3.25s
✅ REPOSITORY trivy yes no no 8.92s
✅ REPOSITORY trivy-sbom yes no no 0.37s
✅ REPOSITORY trufflehog yes no no 3.64s

Detailed Issues

⚠️ REPOSITORY / grype - 1 warning
warning: A medium vulnerability in github-action package: anthropics/claude-code-action, version v1 was found at: /.github/workflows/claude.yml

warning: 1 warnings emitted
⚠️ BASH / shfmt - 1 error
diff actions/instrument/job/inject_and_init.sh.orig actions/instrument/job/inject_and_init.sh
--- actions/instrument/job/inject_and_init.sh.orig
+++ actions/instrument/job/inject_and_init.sh
@@ -18,7 +18,7 @@
   }
   export -f only_job_run
   # shellcheck disable=SC2016 # the expressions are expanded by the inner shell
-  ( nohup setsid bash -c 'echo "only_job_pid=$$" >>"$GITHUB_STATE"; trap "only_job_run &>/tmp/opentelemetry_shell.github.only_job.log; echo \$? >/tmp/opentelemetry_shell.github.only_job.exit_code; exit 0" SIGUSR1; while true; do sleep 1; done' &>/dev/null & )
+  (nohup setsid bash -c 'echo "only_job_pid=$$" >>"$GITHUB_STATE"; trap "only_job_run &>/tmp/opentelemetry_shell.github.only_job.log; echo \$? >/tmp/opentelemetry_shell.github.only_job.exit_code; exit 0" SIGUSR1; while true; do sleep 1; done' &>/dev/null &)
 fi
 
 if [ "${ASYNC_INIT:-FALSE}" = TRUE ]; then

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@plengauer
plengauer disabled auto-merge December 4, 2026 12:29
@plengauer
plengauer merged commit 40a713d into main Dec 4, 2026
61 of 63 checks passed
@plengauer
plengauer deleted the claude/exciting-fermat-k78xlf branch December 4, 2026 12:29
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.

2 participants