diff --git a/config/docker/headless-serve-shutdown/run-signal-case.sh b/config/docker/headless-serve-shutdown/run-signal-case.sh index fd64d7e72da..1dff2a3f60d 100755 --- a/config/docker/headless-serve-shutdown/run-signal-case.sh +++ b/config/docker/headless-serve-shutdown/run-signal-case.sh @@ -60,6 +60,11 @@ ready_line=$(timeout "$startup_timeout_seconds" bash -c ' | sed -u -n 's/^[^{]*//p' \ | jq --unbuffered -Rnc '\''first(inputs | fromjson? | select(.type == "orca_server_ready" and .schemaVersion == 1))'\'' ' bash "$app_pid" "$stdout_log" || true) +# A readiness event can land as the timeout tears down the tail pipeline. +if [[ -z "$ready_line" ]]; then + ready_line=$(sed -u -n 's/^[^{]*//p' "$stdout_log" \ + | jq --unbuffered -Rnc 'first(inputs | fromjson? | select(.type == "orca_server_ready" and .schemaVersion == 1))') +fi if [[ -z "$ready_line" ]]; then cat "$stdout_log" "$stderr_log" >&2 echo "FAIL: entrypoint exited or timed out before orca_server_ready" >&2 diff --git a/config/scripts/headless-serve-shutdown-workflow.test.mjs b/config/scripts/headless-serve-shutdown-workflow.test.mjs index e38a2c909b6..371ce65a909 100644 --- a/config/scripts/headless-serve-shutdown-workflow.test.mjs +++ b/config/scripts/headless-serve-shutdown-workflow.test.mjs @@ -70,6 +70,10 @@ describe('headless serve shutdown PR gate', () => { it('keeps the readiness parser line-buffered', () => { expect(signalCase).toContain("| sed -u -n 's/^[^{]*//p'") + expect(signalCase).toContain( + 'A readiness event can land as the timeout tears down the tail pipeline.' + ) + expect(signalCase).toContain('ready_line=$(sed -u -n') }) it('checks that a serving-electron signal target owns the ready socket', () => {