Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite dev watcher breaks with "EBUSY: resource busy or locked" #19117

Open
7 tasks done
Joelsz opened this issue Jan 1, 2025 · 2 comments
Open
7 tasks done

Vite dev watcher breaks with "EBUSY: resource busy or locked" #19117

Joelsz opened this issue Jan 1, 2025 · 2 comments

Comments

@Joelsz
Copy link

Joelsz commented Jan 1, 2025

Describe the bug

Hi, I'm using Vite to build a Cloudflare Pages project. When starting the dev server it always fails with the following error, sometimes immediately sometimes after a few file changes.

As per #13234 this should've been fixed in 5.0.0, however, it still breaks here.

npx vite -v
vite/5.4.11 win32-x64 node-v22.12.0`
npx vite dev

  VITE v5.4.11  ready in 14166 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
node:events:502
      throw er; // Unhandled 'error' event
      ^

Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (file:///C:/Users/user/dev/project-name/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:44480:10)
    at NodeFsHandler._boundHandleError (file:///C:/Users/user/dev/project-name/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:42953:43)
    at ReaddirpStream.emit (node:events:524:28)
    at ReaddirpStream.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'lstat',
  path: 'C:\\DumpStack.log.tmp'
}

Node.js v22.12.0

This is my vite.config.ts:

import pagesBuild from '@hono/vite-cloudflare-pages'
import adapter from '@hono/vite-dev-server/cloudflare'
import honox from 'honox/vite'
import client from 'honox/vite/client'
import { defineConfig } from 'vite'

export default defineConfig(({ mode }) => {
  let options;
  if (mode === 'client') {
    options = {
      build: {
        rollupOptions: {
          input: ['/app/style.css'], 
          output: {
            assetFileNames: 'static/assets/[name].[ext]'
          }
        },
      },
      plugins: [client()]
    }
  } else {
    options = {
      plugins: [
        honox({
          devServer: {
            adapter
          }
        }),
        pagesBuild()
      ]
    }
  }
  return options;
})

Reproduction

https://github.com/lauragift21/staff-directory/

Steps to reproduce

Run npm install followed by npx vite dev.

Wait for the server to start up, then proceed to making some file changes.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1365U
    Memory: 2.47 GB / 15.35 GB
  Binaries:
    Node: 22.12.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (129.0.2792.79)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    vite: ^5.0.12 => 5.4.11

Used Package Manager

npm

Logs

No response

Validations

@hi-ogawa
Copy link
Collaborator

hi-ogawa commented Jan 2, 2025

We had a report on Vitest vitest-dev/vitest#5740 and this seems to due to some virtual module path (e.g. /@react-refresh by react plugin).

@Joelsz
Copy link
Author

Joelsz commented Jan 3, 2025

Interestingly enough, adding the following ignoreWatching to the config fixed the issue for now.

devServer: {
  ignoreWatching: ['*', /\.wrangler/],
  adapter
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants