Skip to content

Exclude trace files from directory deletion in builds#92486

Merged
lukesandberg merged 2 commits into
canaryfrom
windows_is_racy_when_closing_files_wtf
Apr 13, 2026
Merged

Exclude trace files from directory deletion in builds#92486
lukesandberg merged 2 commits into
canaryfrom
windows_is_racy_when_closing_files_wtf

Conversation

@lukesandberg
Copy link
Copy Markdown
Contributor

@lukesandberg lukesandberg commented Apr 8, 2026

On Windows, open file handles lock files — if the trace write stream happened to be open during cleanDistDir, deleting {distDir}/trace would fail with EPERM/EBUSY.

TBH: because we batch writes to the file this basically shouldn't happen, but this approach is much clearer.

Two changes:

  • Exclude trace* files from the cleanDistDir deletion (alongside cache, dev, lock), so the clean step never races with an open write stream.
  • Open the trace file with flags: 'w' (truncate) for production builds so each build gets a fresh trace file, and 'a' (append) for dev so traces accumulate across hot reloads.

Fixes #92298.

instead just truncate when opening them in builds
Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@nextjs-bot
Copy link
Copy Markdown
Contributor

nextjs-bot commented Apr 8, 2026

Tests Passed

@lukesandberg lukesandberg marked this pull request as ready for review April 8, 2026 00:31
@lukesandberg lukesandberg requested a review from wbinnssmith April 8, 2026 00:31
@nextjs-bot nextjs-bot added created-by: Turbopack team PRs by the Turbopack team. type: next labels Apr 8, 2026
@lukesandberg lukesandberg merged commit cfa01a5 into canary Apr 13, 2026
305 of 310 checks passed
Copy link
Copy Markdown
Contributor Author

Merge activity

@lukesandberg lukesandberg deleted the windows_is_racy_when_closing_files_wtf branch April 13, 2026 20:33
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EPERM: operation not permitted error during next build on Windows with Next.js 15.5.14

3 participants