Skip to content

fix: surface anvil boot failures instead of looping - #90

Merged
naps62 merged 2 commits into
mainfrom
error
Aug 26, 2026
Merged

fix: surface anvil boot failures instead of looping#90
naps62 merged 2 commits into
mainfrom
error

Conversation

@naps62

@naps62 naps62 commented Aug 26, 2026

Copy link
Copy Markdown
Member

A stack whose options anvil rejects exits 2 before opening its RPC port. Anvil's message went only to the in-memory log queue, so prod logged nothing but our own 10s readiness timeout, and every later request paid the same 10s and failed with "Stack not found".

  • Failed boots now log anvil's last output lines and its exit status.
  • Exit 2 (clap rejected the arguments) marks the stack failed; later requests answer immediately. Other exit codes — unreachable fork, bound port — stay resumable.
  • ensure_running/2 returns {:error, reason}, so the proxy reports the exit code instead of "Stack not found".
  • fork_block_number without fork_url is now a changeset error. It is one of the ways to reach exit 2.
  • Caller flags colliding with --port/--state/--host/--chain-id/--preserve-historical-states are dropped. A repeated flag is a clap error, not a last-one-wins override, so the ordering added in fdea60c did not make them safe.
  • One http port per stack, held for its lifetime. Each resume claimed a new port and leaked the old one, and the port claimed in init/1 leaked immediately. Suspend waits for the process to exit before the port can be rebound.

The second commit bumps credo and mix_test_watch: neither compiles on OTP 28, which the devenv shell now provides, so the suite could not run at all. .tool-versions still pins otp-27.

Verification
104 tests, 0 failures

Behaviour confirmed against anvil 1.8.0-nightly. Exit 2 cases: --fork-block-number without --fork-url, --no-mining with --block-time, --mixed-mining without --block-time, and any repeated flag. A test now reproduces the first and asserts the logged output:

Failed to start anvil for badopts: :timeout, anvil exited with 2, last output:
error: the following required arguments were not provided: | --fork-url <URL>

🤖 Generated with Claude Code

naps62 and others added 2 commits August 26, 2026 14:40
A stack whose options anvil rejects exited 2 before opening its RPC
port, and all that reached the logs was our own 10s readiness timeout —
anvil's message went only to the in-memory log queue. Every later
request paid the same 10s and failed the same way.

- log anvil's last output lines when a boot fails, with its exit status
- keep :failed after a clap usage error (exit 2), since the args cannot
  change while the process lives; other exits stay resumable
- ensure_running/2 returns {:error, reason}, so the proxy reports why
  instead of "Stack not found"
- reject fork_block_number without fork_url, which is one way to hit
  exit 2
- drop caller flags that collide with server-managed ones: a repeated
  flag is a clap error, not a last-one-wins override
- hold one http port per stack for its lifetime; every resume claimed a
  new one and leaked the old, and suspend now waits for the process to
  die before the port can be rebound

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both fail to compile on OTP 28, which the devenv shell now provides:
credo hits a PCRE2 character-class error, mix_test_watch escapes a
reference into a struct default. Neither is reachable from the release.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stacks Ready Ready Preview Aug 26, 2026 1:45pm

Request Review

@naps62
naps62 merged commit ce182dd into main Aug 26, 2026
3 checks passed
@naps62
naps62 deleted the error branch August 26, 2026 13:50
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