Skip to content

Await the tests/target and tests/trybuild probes in cleanup - #387

Open
jeremy wants to merge 1 commit into
Swatinem:masterfrom
jeremy:await-tests-probes
Open

Await the tests/target and tests/trybuild probes in cleanup#387
jeremy wants to merge 1 commit into
Swatinem:masterfrom
jeremy:await-tests-probes

Conversation

@jeremy

@jeremy jeremy commented Sep 10, 2026

Copy link
Copy Markdown

In cleanProfileTarget, the tests branch probes tests/target and tests/trybuild inside try {} catch {} blocks, but calls cleanTargetDir without await. cleanTargetDir is async and its first step is fs.promises.opendir(targetDir), so when either directory is missing the rejection escapes the try as an unhandled promise rejection. The runner prints it as an error annotation on the job:

Error: ENOENT: no such file or directory, opendir '.../tests/trybuild'

Any crate whose target/ contains a directory named tests without those nested dirs triggers it, e.g. the unpacked crate cargo package leaves at target/package/<crate>-<version>/tests. The job still succeeds, but each probe adds two annotations. Example at v2.9.2 (6323deb), 8 annotations across two jobs: https://github.com/basecamp/hey-sdk/actions/runs/34460215462

This adds await to both calls so the existing catch swallows the ENOENT as intended. Nothing else in src/ changes.

dist/ is rebuilt with npm run prepare. The cleanup chunk differs only by the two awaits; the large cache chunk also loses the CRLF line endings that #377 committed without running linefix, which is why check-dist has been failing on master since then (https://github.com/Swatinem/rust-cache/actions/runs/31616391478). diff -w between the old and new cache chunks is empty.

`cleanProfileTarget` probes `tests/target` and `tests/trybuild` inside
`try {} catch {}` blocks, but calls `cleanTargetDir` without `await`.
`cleanTargetDir` is async and opens the directory with
`fs.promises.opendir` as its first step, so when either directory is
absent the rejection is never caught by the surrounding `try` and
surfaces as an unhandled promise rejection. The GitHub runner prints it
as an error annotation on the job:

    Error: ENOENT: no such file or directory, opendir '.../tests/trybuild'

This happens for any crate whose `target/` contains a directory named
`tests` without those nested dirs, e.g. the crate `cargo package`
unpacks under `target/package/<crate>-<version>/tests`. The job still
succeeds, but each probe leaves two annotations behind.

Awaiting both calls lets the existing `catch` swallow the ENOENT as
intended.

`dist/` is rebuilt with `npm run prepare`. Beyond the two `await`s in
the cleanup chunk, this also strips the CRLF line endings that Swatinem#377
committed in the large cache chunk without running `linefix`, which is
why `check-dist` has been failing on master since then.
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