next.js
d0abfdb9 - [test] Retry the `.next` deletion to fix an `ENOTEMPTY` flake (#95307)

Commit
12 days ago
[test] Retry the `.next` deletion to fix an `ENOTEMPTY` flake (#95307) The `watch-distdir-deletion` dev test deletes `.next` to verify that the dev server notices its distDir (`.next/dev`) being removed and restarts. The deletion frequently failed in CI with `ENOTEMPTY: directory not empty, rmdir '.../.next/dev'`. The cause is a race between the test's recursive delete and the dev server's own writes. After the warmup request returns, Turbopack keeps flushing manifests into `.next/dev` through its background update subscription, and `writeFileAtomic` does so by creating a transient temporary file and renaming it over the target. `fs.rm` removes a directory by reading its entries, unlinking them, and then calling `rmdir`; when the server writes a new file into `.next/dev` between the unlink pass and the `rmdir`, the `rmdir` throws `ENOTEMPTY`. The test only passed `force: true`, which suppresses `ENOENT` but not `ENOTEMPTY`, so the first such collision failed the test outright. Resource contention on CI widens the window, which is why it failed so often. This change passes `maxRetries` and `retryDelay` to the same `fs.rm` call so the failed `rmdir` is re-attempted across that brief window until the flush settles, instead of failing on the first collision. The deletion stays a plain recursive remove. Run twenty times concurrently on an oversubscribed machine, the test went from a 45% failure rate to passing every time, with the distDir-deletion watcher still firing in every run.
Author
Parents
Loading