Skip to content

[release-tools] Improve handling a root package to avoid the "EEXIST" error #19550

@pomek

Description

@pomek

📝 Provide detailed reproduction steps (if any)

When the files field in rootPackageJson contains nested paths or overlapping glob patterns, the prepareRepository() task may fail with the EEXIST error.

This occurs because multiple asynchronous fs.cp() calls attempt to create the same intermediate directories or copy to overlapping destinations concurrently.

  1. Set rootPackageJson.files to include multiple nested globs, e.g.:

    {
      "files": ["src/**/*", "src/**/index.js"]
    }
  2. Run the prepareRepository() function.

  3. From time to time, the EEXIST error occurs.

✔️ Expected result

All files matched by the files patterns should be copied to the output directory without race conditions or unexpected filesystem errors.

❌ Actual result

The operation sometimes fails with EEXIST errors on random files, depending on filesystem timing and concurrency.

📃 Other details

Calling fsPromises.mkdir() when path is a directory that exists results in a rejection only when recursive is false.

https://nodejs.org/docs/latest-v24.x/api/fs.html#fspromisesmkdirpath-options

Metadata

Metadata

Assignees

Labels

package:devsquad:platformIssue to be handled by the Platform team.type:bugThis issue reports a buggy (incorrect) behavior.

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions