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

频繁出现报错 resource busy or locked, lstat 'C:\DumpStack.log.tmp' #3603

Open
aliuq opened this issue Jun 14, 2022 · 18 comments
Open

频繁出现报错 resource busy or locked, lstat 'C:\DumpStack.log.tmp' #3603

aliuq opened this issue Jun 14, 2022 · 18 comments

Comments

@aliuq
Copy link

aliuq commented Jun 14, 2022

问题描述

vite vue3 ts项目在文件监听过程中,操作一段时间就会出现错误信息

复现步骤

https://github.com/aliuq/mp-uniapp-vite-vue3

启动项目,编辑页面,几分钟就会出现报错

预期结果

正常运行

实际结果

DONE  Build complete. Watching for changes...
events.js:377
      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 (C:\Users\linka\Projects\mp-uniapp-vite-vue3\node_modules\.pnpm\rollup@2.75.6\node_modules\rollup\dist\shared\index.js:4239:10)
    at ReaddirpStream.NodeFsHandler$1._boundHandleError (C:\Users\linka\Projects\mp-uniapp-vite-vue3\node_modules\.pnpm\rollup@2.75.6\node_modules\rollup\dist\shared\index.js:2715:43)
    at ReaddirpStream.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'lstat',
  path: 'C:\\DumpStack.log.tmp'
}

系统信息:

  • 发行平台: 微信小程序
  • uni-app版本 3.0.0-alpha-3040820220424001
  • 设备信息 微信开发者工具
@ChenChunChang
Copy link

ChenChunChang commented Sep 15, 2022

你好,我也遇到了,我将vite降级到2.9.5还是会出现这种情况,请问你解决了吗

@yzlhdy
Copy link

yzlhdy commented Nov 4, 2022

解决了吗

@aliuq
Copy link
Author

aliuq commented Nov 8, 2022

@ChenChunChang @yzlhdy 有一段时间没用了

@ChenChunChang
Copy link

@ChenChunChang @yzlhdy 有一段时间没用了

好吧,这是个神奇的问题

@1SZX1
Copy link

1SZX1 commented Nov 9, 2022

不用unocss就没问题,很难受

@tianyu94
Copy link

同样的问题

@firebat1314
Copy link

我把项目从SSD移动到机械硬盘可以解决这个问题

KeJunMao added a commit to uni-helper/vitesse-uni-app that referenced this issue May 25, 2023
@xiaoyang-web
Copy link

不知道咋解决,在windows系统下,目前我是这样解决的:
首先关闭虚拟内存,然后关闭睡眠模式(powercfg -h off),然后相应的情况不会出现了。

@KeJunMao
Copy link

/ 开头的导入在 vite 的 watch 模式下都有这个问题(unocss 的 resolveId 是 /__uno.css):

补充几个 issue:

我自己的解决方案:

  1. 固定 unocss 的版本号,例如 0.52.3
  2. pnpm patch @unocss/vite@0.52.3
  3. 修改其 dist/index.cjs
...
-const RESOLVED_ID_WITH_QUERY_RE = /[\/\\]__uno(?:(_.*?))?\.css(\?.*)?$/;
-const RESOLVED_ID_RE = /[\/\\]__uno(?:(_.*?))?\.css$/;
+const RESOLVED_ID_WITH_QUERY_RE = /__uno(?:(_.*?))?\.css(\?.*)?$/;
+const RESOLVED_ID_RE = /__uno(?:(_.*?))?\.css$/;
...
-      return match[1] ? `/__uno_${match[1]}.css` : "/__uno.css";
+      return match[1] ? `__uno_${match[1]}.css` : "__uno.css";
...
  1. 提交修改

详细修改可以参考这个 commit: uni-helper/vitesse-uni-app@9341828

@like0413
Copy link

like0413 commented Jun 2, 2023

我遇到类似的问题,一旦修改代码保存就报错。我把unocss去掉了就不报错了,很烦,有没有解决办法

DONE  Build complete. Watching for changes...
运行方式:打开 微信开发者工具, 导入 dist\dev\mp-weixin 运行。
ready in 8167ms.

node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: EBUSY: resource busy or locked, lstat 'D:\pagefile.sys'
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (file:///D:/Program/%E7%94%9F%E4%BA%A7%E9%A1%B9%E7%9B%AE/uniapp-vue3-template/node_modules/.pnpm/rollup@3.23.0/node_modules/rollup/dist/es/shared/watch.js:4246:10)
    at ReaddirpStream.NodeFsHandler._boundHandleError (file:///D:/Program/%E7%94%9F%E4%BA%A7%E9%A1%B9%E7%9B%AE/uniapp-vue3-template/node_modules/.pnpm/rollup@3.23.0/node_modules/rollup/dist/es/shared/watch.js:2720:43)
    at ReaddirpStream.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'lstat',
  path: 'D:\\pagefile.sys'
}
 ELIFECYCLE  Command failed with exit code 1.

@StrivingRabbit
Copy link
Collaborator

vite.config.js 中添加以下代码:

defineConfig({
  // ...
  build: {
		watch: {
			exclude: ['node_modules/**', "/__uno.css"]
		},
	}
})

重新运行项目试试看

@yasz
Copy link

yasz commented Oct 8, 2023

对于没有使用unocss报错的情况呢?

@zcf0508
Copy link

zcf0508 commented Dec 1, 2023

使用 pnpm 覆写版本可以解决这个问题

// package.json
"pnpm": {
    "overrides": {
      "vite": "^4.4.9",
      "rollup": "^4"
    }
  }

@Otto-J
Copy link
Member

Otto-J commented Dec 4, 2023

使用 pnpm 覆写版本可以解决这个问题

// package.json
"pnpm": {
    "overrides": {
      "vite": "^4.4.9",
      "rollup": "^4"
    }
  }

能解释这样做的原因吗?我以为这是操作系统对资源处理有问题导致的,是构建工具导致的?

@zcf0508
Copy link

zcf0508 commented Dec 5, 2023

@Otto-J

rollup/rollup#5013

https://github.com/rollup/rollup/pull/5150/files#diff-1d2d86a9be3305dbb026a6b14b2179c8fcbb04c9861873f70f2ed6447a286ac6

我也不是很清楚,不过升级之后确实是好了。可以看一下上面相关的内容

@StrivingRabbit
Copy link
Collaborator

相关:

尝试两种解决办法:

  1. vite.config.js 中添加以下代码:

    defineConfig({
      // ...
      build: {
    	    watch: {
    		    exclude: ['node_modules/**', "/__uno.css"]
    	    },
        }
    })

    重新运行项目

  2. 更改依赖版本

    使用 pnpm 覆写版本可以解决这个问题

    // package.json
    "pnpm": {
        "overrides": {
          "vite": "^4.4.9",
          "rollup": "^4"
        }
      }

@KeJunMao
Copy link

KeJunMao commented Dec 6, 2023

如果是因为 unocss 引起的问题,直接使用 unocss-preset-uni 即可

其背后的原理是安装后应用了一个 patch,它修改了 unocss 的 resolveId:/__uno.css -> __uno.css

升级到 vite 5.x 之后,就不再需要这个 patch 了(虽然打上也不影响)

@mirari
Copy link

mirari commented Jan 29, 2024

今天也遇到了类似问题,尝试重启、删除lock文件、删除node_modules目录、修改磁盘访问权限、更换项目目录、更换yarn安装都不行
最后发现是rollup的bug。
没有使用unocss,但有使用tailwind。
将package.json中的vite强制升级到5.x以后解决了。

uniapp相关依赖会有警告,不影响运行,就忽略了

├─┬ @dcloudio/uni-automator 3.0.0-alpha-4000020240127001
│ └─┬ @dcloudio/uni-cli-shared 3.0.0-alpha-4000020240127001
│   └─┬ @vue/server-renderer 3.3.11
│     └── ✕ unmet peer vue@3.3.11: found 3.3.12
└─┬ @dcloudio/vite-plugin-uni 3.0.0-alpha-4000020240127001
  ├── ✕ unmet peer vite@^4.0.0: found 5.0.12
  └─┬ @vitejs/plugin-legacy 4.1.1
    └── ✕ unmet peer vite@^4.0.0: found 5.0.12

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

No branches or pull requests