Skip to content

Fix async file operations in validator - #34062

Open
luojiyin1987 wants to merge 1 commit into
uBlockOrigin:masterfrom
luojiyin1987:agent/fix-validate-file-race
Open

Fix async file operations in validator#34062
luojiyin1987 wants to merge 1 commit into
uBlockOrigin:masterfrom
luojiyin1987:agent/fix-validate-file-race

Conversation

@luojiyin1987

Copy link
Copy Markdown

Fixes #34061.

Summary

The validator now waits for each partial result write.
It waits for both final result writes in parallel.
It removes the partial result only after all writes finish.
The removal uses the force option.

Root cause

The writeFile helper added each write after an earlier await.
Promise.all could inspect writeOps before those writes entered the array.
The partial file removal also ran without await.

Impact

The validator now completes all output writes before it exits.
A missing partial result file no longer causes ENOENT.
Pending writes cannot recreate the partial file after cleanup.
The output paths and formats stay unchanged.

Checks

  • node --check tools/validate/validate.js
  • git diff --check
  • The original lifecycle test exits with ENOENT.
  • The fixed lifecycle test exits with status zero.
  • Both final files exist after the fixed test.
  • The partial file does not exist after the fixed test.

The lifecycle test uses a temporary directory.
It disables external DNS queries in the ignored build copy.

@luojiyin1987
luojiyin1987 marked this pull request as ready for review August 11, 2026 15:57
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.

Fix async file race in validate.js

1 participant