Skip to content

fix(runner): report a runtime's crash output instead of waiting for the startup timeout - #276

Merged
HarshMN2345 merged 11 commits into
mainfrom
fix-runtime-crash-logs
Nov 13, 2026
Merged

HarshMN2345 merged 11 commits into
mainfrom
fix-runtime-crash-logs

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

When a runtime's server exits before it starts listening, an execution now fails fast with runtime_failed and the tail of the runtime's output. Before, the executor kept pinging the port until the startup timeout, then returned "Timed out waiting for runtime." with nothing about why.

  • Crash check: while waiting for the port, the runner inspects the container (docker container inspect) and treats restarting, exited or dead as a crash.
    • The first check comes once the runtime is 2 s old, then every 3 s, so a healthy cold start that listens within 2 s runs none. This holds for requests that join a cold start too.
    • A running container is never reported, so a runtime that crashed once and recovered under restartPolicy: always keeps serving.
    • Both docker commands have a 5 s timeout. If inspect fails or times out, the loop keeps waiting as before.
  • Message: "Runtime crashed while starting (exit code N[, out of memory]):" followed by the last 100 log lines, capped at 10 KB and converted to valid UTF-8.
    • The output is left out when the execution has logging disabled.
    • If docker logs fails, only the sentence is used.
  • Readiness ping: uses a 1 s connect timeout. A gone container's stale address dropped the connect for the full 10 s default. The loop pings again every 0.5 s, so a slow but healthy start is unaffected.

testRestartPolicy now uses a Node function that answers 500 and then ends its process. Its old PHP fixture relied on exit() killing the server, which open-runtimes 0.13.45 no longer allows (it answers 500 and keeps serving). main fails this test since then.

PHPStan (composer analyze), Pint and Rector are clean, and E2E passes in CI.

@appwrite

appwrite Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The runner now checks Docker container state during readiness polling and returns startup-crash errors with bounded runtime output, while using a shorter readiness connection timeout. The restart-policy E2E fixture now exits from a Node function after returning 500; the prior PHP fixture and startup-crash/recovery E2E cases are removed.

Latest changes: The newest commit removes the startup-crash and restart-after-recovery E2E cases while leaving the restart-policy test in place.

Verdict New comments Fixed Still open
✅ Approved 0 0 0

Couldn't attach to a line

These findings could not be placed on a changed line, so they were not posted as inline comments.

📂 Walkthrough · 6
File Change
src/Executor/Runner/Docker.php Detects crashed containers while waiting for readiness and reports an exit reason with bounded optional logs.
tests/e2e/ExecutorTest.php Uses the Node exit fixture for restart-policy coverage and removes the startup-crash and recovery cases.
tests/resources/functions/node-exit/index.js, tests/resources/functions/node-exit/package.json Adds a Node fixture that returns HTTP 500 and then exits, triggering the runtime restart policy.
tests/resources/functions/php-exit/index.php Removes the PHP exit fixture previously used by the restart-policy test.
tests/resources/functions/node-exit/index.js Adds a function fixture that returns an error and exits to exercise runtime restarts.
tests/resources/functions/node-exit/package.json Adds package metadata for the Node exit fixture.

Reviewed the commits since 1a94be2 · Details · Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Tier B · 1 blocking finding to address. Summary

Comment thread src/Executor/Runner/Docker.php Resolved

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@HarshMN2345
HarshMN2345 merged commit 5e2a5d4 into main Nov 13, 2026
12 of 13 checks passed
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.

1 participant