Skip to content

Concurrency issue with prepareVueTsc function #557

@kitsune7

Description

@kitsune7

Describe the bug

When running Vite's dev server in a monorepo with a micro-frontend architecture (multiple apps need to run at once to load different pages and sections of the site), prepareVueTsc is called multiple times in parallel. This causes errors.

I believe most of the issues step from the logic inside the if (shouldBuildFixture) block, which is in the prepareVueTsc function.

Not a ton of people use the kind of architecture that would run this function several times in parallel, but it highlights an issue where this logic really just needs to run once after dependencies have been installed. I can get around the issue by just running a single app by itself long enough for the plugin to get the right files set up in node_modules, but in a project with a large number of contributors, this problem adds a lot of extra friction to the setup.

Could we maybe have a postinstall script that runs this logic? Or if not, maybe we can implement a file-based mutex lock to prevent file conflicts?

Reproduction

  1. Run npm install (or the equivalent command for your package manager) on a project that runs vite-plugin-checker with Vite's dev server
  2. Ensure that the project uses npm workspaces (or a similar equivalent for other package managers) where multiple apps use the same base node_modules directory
  3. Run npm run dev for each app so that they start in parallel

Expected behavior

vite-plugin-checker has the ability to be run in parallel without issues after it's installed to node_modules. Any typescript issues are logged to the console.

System Info

System:
    OS: macOS 15.6
    CPU: (12) arm64 Apple M3 Pro
    Memory: 5.63 GB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 11.5.2 - /opt/homebrew/bin/npm
    pnpm: 10.13.1 - /opt/homebrew/bin/pnpm
    bun: 1.2.2 - ~/.bun/bin/bun
  Browsers:
    Safari: 18.6
  npmPackages:
    vite-plugin-checker: ^0.10.2 => 0.10.2

Additional context

Here are some of the errors that I see when running things in parallel:

node:internal/event_target:1101
  process.nextTick(() => { throw err; });
                           ^
[Error: ENOTEMPTY: directory not empty, rmdir '<my_project_path>/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib'] {
  errno: -66,
  code: 'ENOTEMPTY',
  syscall: 'rmdir',
  path: '<my_project_path>/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib'
}
node:internal/event_target:1101
  process.nextTick(() => { throw err; });
                           ^
Error: ENOENT: no such file or directory, copyfile '/<my_project_path>/node_modules/typescript/lib/typesMap.json' -> '/<my_project_path>/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib/typesMap.json'
    at async copyFile (node:internal/fs/promises:620:10)
    at async _copyFile (node:internal/fs/cp/cp:260:3)
    at async copyDir (node:internal/fs/cp/cp:320:19)
    at async mkDirAndCopy (node:internal/fs/cp/cp:309:3)
    at async copyDir (node:internal/fs/cp/cp:320:19)
    at async prepareVueTsc (file:///<my_project_path>/node_modules/vite-plugin-checker/dist/checkers/vueTsc/prepareVueTsc.js:44:5)
    at async Object.configureServer (file:///<my_project_path>/node_modules/vite-plugin-checker/dist/checkers/vueTsc/main.js:36:31) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'copyfile',
  path: '/<my_project_path>/node_modules/typescript/lib/typesMap.json',
  dest: '/<my_project_path>/node_modules/vite-plugin-checker/dist/checkers/vueTsc/typescript-vue-tsc/lib/typesMap.json'
}

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions