Skip to content

An xtask test fails now and then with Text file busy #232

Closed

Description

@fctl-sh

What is wrong

cargo xtask check, and CI's test job, which runs the same cargo test --workspace, can fail in xtask's util::tests::runs_a_throttled_command_again (added in #230):

called `Result::unwrap()` on an `Err` value: starting "/tmp/xtask-throttled-once-32652/wrangler"

Caused by:
    Text file busy (os error 26)

It failed once in a cargo xtask check in session #175, on a branch that doesn't touch xtask, while the machine was busy. Afterwards, xtask's tests passed in 12 runs out of 12, and CI on main has passed so far.

How it works now

Three tests in xtask/src/util.rs (runs_a_throttled_command_again, gives_up_on_a_command_the_api_keeps_throttling and runs_other_failures_once) each write a stand-in wrangler script with std::fs::write, make it executable and run it, on parallel threads of one test process. One test can fork to start its script while another test still has its own script open for writing. The child keeps that file open until it execs, and running the second script in that window fails with ETXTBSY.

What should happen

The tests pass every time, under load too:

  • Write and start the stand-in scripts so that no fork can catch one open for writing: one lock around writing and spawning in the test helper, a retry of the spawn on ETXTBSY, or these tests running one at a time. (test: fix xtask tests that fail now and then with Text file busy #253: sh writes them, so the test binary never has one open; 0 of 6,120 runs failed after it, 6 of 2,040 before)

Compatibility

Tests only: nothing ships.

Session: https://app.fctl.sh/s/ses_01M5MFGRENHK8PHRFQXJ53360Z

Activity

  1. added
    bug
    release
    on Oct 23, 2026
  2. fctl-sh commented on Oct 24, 2026

    @fctl-sh
    ContributorAuthor

    Seen again in CI on #251, in runs_other_failures_once this time, where the race hides behind another error. The spawn fails with Text file busy (os error 26), but the test expects retry_throttled to fail anyway, so unwrap_err() takes the spawn error, and runs() then panics on the missing .runs file:

    thread 'util::tests::runs_other_failures_once' panicked at xtask/src/util.rs:397:14:
    called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
    

    Locally, cargo test -p xtask --bin xtask util::tests failed this way in 1 of 20 runs, and in run 45 of another loop where the test printed the error it swallows: starting "/tmp/xtask-denied-…/wrangler": Text file busy (os error 26). Besides the race itself, the fix could have that test check that its error is the stand-in's, not a failure to start it.

  3. fctl-sh commented on Oct 24, 2026

    @fctl-sh
    ContributorAuthor

    Fixed by #253, merged as 13fbde3. It changes only tests and AGENTS.md, so there's nothing to deploy or release. Branches made from an older main can still hit this flake until they merge main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugrelease

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions