Fix CLI local function emulation for OpenRuntimes v5#1454
Fix CLI local function emulation for OpenRuntimes v5#1454ChiragAgg5k merged 7 commits intomasterfrom
Conversation
Greptile SummaryThis PR fixes Confidence Score: 5/5Safe to merge — all prior P1 findings are addressed and no new blocking issues were found. All three issues from the previous review round are resolved. The waitForProcessOutput Promise technically never settles when the process exits without emitting the needle, but this is fully mitigated by the 1500ms timeout in the downstream Promise.race. Remaining observations are P2 style concerns that don't block correctness. templates/cli/lib/emulation/docker.ts warrants a quick read for the two-phase startup detection logic, but no blocking issues remain. Important Files Changed
Reviews (5): Last reviewed commit: "Refine CLI local run output" | Re-trigger Greptile |
Summary
This fixes
appwrite run functionin the CLI SDK for current OpenRuntimes v5 images, fixes the local runtime startup command so functions actually stay up after a successful build, and adds a regression test so this path is covered in future CLI test runs.What changed
openruntimes/*:v4-*toopenruntimes/*:v5-*sh helpers/server.shtobash helpers/server.shbecause the v5 helper uses bash-only features likeshoptappwrite run functionstops immediately instead of continuing into misleading build/start steps after a Docker failurebash helpers/server.sh, and keeps the Docker failure-handling guards in the generated CLI sourceProblem
appwrite run functionin the generated CLI was still targeting v4 OpenRuntimes tags. For a current runtime likenode-25, the local runner tried to useopenruntimes/node:v4-25, which does not exist.It also ignored non-zero Docker exits, so the command kept going into build/start even after the image lookup failed.
After switching the image tag to v5, local startup still failed because the generated start command invoked
helpers/server.shwithsh, but the v5 helper script is a bash script.Before
Compiled from
examples/cliwith:Observed output before this fix:
Observed output after only switching the image tag, before fixing the startup shell:
The container exited immediately after that and
curl http://127.0.0.1:3137/failed.After
Verified with the same loop from
examples/cli:Observed output after this fix:
Response from the local function:
{"ok":true,"method":"GET","path":"/"}Docker also shows the local runtime container staying up:
Regression coverage
The existing generated CLI Bun tests now assert:
openRuntimesVersion === "v5"systemTools.node.startCommand === "bash helpers/server.sh"lib/emulation/docker.tsstill contains the explicit Docker failure-handling path for pull/start behaviorThese run through the normal CLI PHPUnit flow via
tests/languages/cli/test.jsand theCLIBun10/11/13test classes.Validation
php example.phpcd examples/cli && bun run mac-arm64cd examples/cli && ./build/appwrite-cli-darwin-arm64 run function --function-id local-run-check --port 3137 --no-reloadcurl -sS http://127.0.0.1:3137/cd examples/cli && bunx eslint lib/emulation/docker.ts lib/emulation/utils.tsvendor/bin/phpunit tests/CLIBun13Test.phpNotes
examples/*is gitignored in this repository, so the generated CLI was regenerated and used for verification but is not part of the committed diff.bun run lintstill reports a large number of unrelated, pre-existing generated CLI lint issues outside the touched local emulation files.