Skip to content

CI: Race condition in esbuild.mjs causing ENOTEMPTY errors #4734

@KJ7LNW

Description

@KJ7LNW

A race condition in the CI environment is causing build failures with ENOTEMPTY errors when multiple processes attempt to clean and write to the same src/dist directory concurrently.

Error Details

roo-cline:test: roo-cline:bundle: [extension] Cleaning dist directory: /home/runner/work/Roo-Code/Roo-Code/src/dist
roo-cline:test: roo-cline:bundle: Error: ENOTEMPTY: directory not empty, rmdir '/home/runner/work/Roo-Code/Roo-Code/src/dist'
roo-cline:test: roo-cline:bundle:     at Object.rmdirSync (node:fs:1215:11)
roo-cline:test: roo-cline:bundle:     at _rmdirSync (node:internal/fs/rimraf:262:21)
roo-cline:test: roo-cline:bundle:     at rimrafSync (node:internal/fs/rimraf:195:7)
roo-cline:test: roo-cline:bundle:     at Module.rmSync (node:fs:1264:10)
roo-cline:test: roo-cline:bundle:     at main (file:///home/runner/work/Roo-Code/Roo-Code/src/esbuild.mjs:39:6)

Root Cause

The pnpm test command executed by the platform-unit-test job uses turbo to run tasks for multiple packages in parallel. The build script src/esbuild.mjs is being executed concurrently by different packages (e.g., roo-cline and @roo-code/types).

This script is not safe for concurrent execution because it cleans and writes to the same shared directory, src/dist. The error occurs when one process attempts to delete the src/dist directory while another process has already started writing new build artifacts back into it.

Reproduction

This issue was triggered in the following CI run:
CI Run #15669447487 (PR #4733)

Possible Solutions

  1. Modify src/esbuild.mjs to allow each package to build to a unique output directory
  2. Configure turbo.json to force the conflicting bundle tasks to run serially
  3. Implement a locking mechanism to prevent concurrent access to the shared directory

@cte

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue - Unassigned / ActionableClear and approved. Available for contributors to pick up.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions