fix(auth): retry spawn on ETXTBSY in the auth-status check - #815
Draft
benw5483 wants to merge 1 commit into
Draft
Conversation
A freshly written executable can transiently report ETXTBSY ("text file
busy") when a concurrent fork in another thread still holds a writable fd
to it across the fork->exec window. The runner spawn paths already route
through spawn_with_etxtbsy_retry; the auth-status check did not, so it
kept spawning the target binary directly.
That gap showed up as an intermittent 'failed to spawn claude: Text file
busy (os error 26)' panic in test_check_auth_async_success under the
instrumented coverage build, which is slow enough to lose the race the
plain test job usually wins. A single panic there aborts lcov.info
generation, so the coverage gate fails with a missing-report error rather
than a real per-file miss.
Route both auth spawn sites through the existing retry helper, sharing one
spawn_auth_child function so the two call sites no longer duplicate the
spawn and its error mapping. This mirrors probe_claude_auth_async, which
runs the same 'claude auth status --json' command and was already covered.
Generated by the operator's software factory.
City: factory-main · Agent: local-core.builder-1
On behalf of: @benw5483
Co-Authored-By: <operator-factory-bot> <factory-bot@actual.invalid>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
claude auth statuscheck through the existingspawn_with_etxtbsy_retryhelper, so a freshly written executable no longer fails the exec withETXTBSY("text file busy").spawn_auth_childfunction betweencheck_auth_asyncandcheck_auth_async_no_json, which previously duplicated the spawn and its error mapping verbatim.Why
The runner spawn paths already retry on
ETXTBSY; the auth-status check was the one that still calledCommand::spawn()directly. That gap surfaced as an intermittentfailed to spawn claude: Text file busy (os error 26)panic intest_check_auth_async_successunder the instrumented coverage build, which runs slowly enough to lose a race the plainTestjob usually wins. A single panic there abortslcov.infogeneration, soCoverage Enforcementfails with a missing-report error rather than a real per-file miss.probe_claude_auth_asyncruns the sameclaude auth status --jsoncommand and was already covered, so this brings the two into line.Test plan
cargo test --workspace --features integration— 3103 passed, 0 failed in the main crate; all nine integration suites green.cargo fmt --checkandcargo clippy -- -D warnings— both clean.cargo llvm-covreproducing the coverage job —cli/commands/auth.rs552/552 lines andrunner/util.rs200/200, with every file in the tree at 100%.The retry branch itself is already covered by the four unit tests on
spawn_with_etxtbsy_retryinsrc/runner/util.rs: first-attempt success, retry-then-succeed, non-ETXTBSYerror not retried, and retries exhausted. No new integration test provokes a realETXTBSY, because it cannot be reproduced portably. Holding a writable file descriptor on a fixture script raises no error on macOS, so such a test would be Linux-only and timing-dependent, which is the opposite of what this change is for.