-
Notifications
You must be signed in to change notification settings - Fork 367
fix(docs-noob-tester): replace STATUS=$(curl) with until curl to survive set -e #28624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -50,11 +50,25 @@ pre-agent-steps: | |||||||||||||||||||||||||||||||||||||
| echo "Server PID: $PID" | ||||||||||||||||||||||||||||||||||||||
| - name: Wait for server readiness | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| for i in {1..45}; do # 45 attempts × 3s = 135s max wait | ||||||||||||||||||||||||||||||||||||||
| STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:4321/gh-aw/) | ||||||||||||||||||||||||||||||||||||||
| [ "$STATUS" = "200" ] && echo "Server ready at http://localhost:4321/gh-aw/!" && break | ||||||||||||||||||||||||||||||||||||||
| echo "Waiting for server... ($i/45) (status: $STATUS)" && sleep 3 | ||||||||||||||||||||||||||||||||||||||
| MAX_WAIT=135 # 45 attempts × 3s = 135s max wait | ||||||||||||||||||||||||||||||||||||||
| WAITED=0 | ||||||||||||||||||||||||||||||||||||||
| until curl -sf http://localhost:4321/gh-aw/ > /dev/null 2>&1; do | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| until curl -sf http://localhost:4321/gh-aw/ > /dev/null 2>&1; do | |
| until curl -sf --connect-timeout 1 --max-time 2 http://localhost:4321/gh-aw/ > /dev/null 2>&1; do |
Copilot
AI
Apr 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crash-detection check uses kill -0 "$(cat /tmp/server.pid)" which is vulnerable to races/invalid contents (e.g., empty/partial PID file) and reintroduces a command substitution in a set -e script. Safer is to read the PID with shell redirection (read -r pid < /tmp/server.pid) and validate it’s a non-empty numeric PID before calling kill -0.
| if [ -f /tmp/server.pid ] && ! kill -0 "$(cat /tmp/server.pid)" 2>/dev/null; then | |
| echo "::error::Documentation server process died before becoming ready. Server log:" | |
| cat /tmp/preview.log | |
| exit 1 | |
| if [ -f /tmp/server.pid ]; then | |
| read -r pid < /tmp/server.pid || pid= | |
| case "$pid" in | |
| ''|*[!0-9]*) | |
| echo "::error::Documentation server PID file is invalid before readiness check. Server log:" | |
| cat /tmp/preview.log | |
| exit 1 | |
| ;; | |
| esac | |
| if ! kill -0 "$pid" 2>/dev/null; then | |
| echo "::error::Documentation server process died before becoming ready. Server log:" | |
| cat /tmp/preview.log | |
| exit 1 | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow imports
shared/docs-server-lifecycle.md, but that shared document’s “Waiting for Server Readiness” section still shows the oldSTATUS=$(curl ...)pattern (shared/docs-server-lifecycle.md:54-58). Consider updating the shared instructions (or noting the newer pattern here) to avoid the prompt/documentation drifting from the actual pre-agent step behavior.