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

🐛 BUG: EBUSY: resource busy or locked, rmdir #4167

Closed
Cherry opened this issue Oct 12, 2023 · 16 comments
Closed

🐛 BUG: EBUSY: resource busy or locked, rmdir #4167

Cherry opened this issue Oct 12, 2023 · 16 comments
Assignees
Labels
bug Something that isn't working

Comments

@Cherry
Copy link
Contributor

Cherry commented Oct 12, 2023

Which Cloudflare product(s) does this pertain to?

Wrangler core

What version(s) of the tool(s) are you using?

3.13.0

What version of Node are you using?

18.18.0

What operating system are you using?

Windows 10

Describe the Bug

  • npm create cloudflare@latest
  • npm run start
  • Every time you exit (via CTRL +C), you'll now get an error like this:
Error: EBUSY: resource busy or locked, rmdir '\\?\C:\Users\james\AppData\Local\Temp\miniflare-dfe8276bbdf83d5203566d99a9aee2e4\cache'
    at rmdirSync (node:fs:1229:10)
    at _rmdirSync (node:internal/fs/rimraf:235:5)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at Object.rmSync (node:fs:1278:10)
    at E:\GitHub\bitter-sun-7847\node_modules\miniflare\dist\src\index.js:7528:27
    at process.exit (E:\GitHub\bitter-sun-7847\node_modules\exit-hook\index.js:15:3) {
  errno: -4082,
  syscall: 'rmdir',
  code: 'EBUSY',
  path: '\\\\?\\C:\\Users\\james\\AppData\\Local\\Temp\\miniflare-dfe8276bbdf83d5203566d99a9aee2e4\\cache'
}

Worker script for context, though it doesn't seem to actually matter if you use cache or not:

export default {
	async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
		const cache = caches.default;
		const response = await cache.match(request);
		if(response){
			return response;
		}
		const finalResponse = new Response('Hello worker!', { status: 200 });
		ctx.waitUntil(cache.put(request, finalResponse.clone()));
		return finalResponse;
	},
};

This is not an issue with wrangler 3.12.

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@Cherry Cherry added the bug Something that isn't working label Oct 12, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Oct 12, 2023
@penalosa penalosa added the start-dev-worker Relating to the startDevWorker API label Oct 12, 2023
@admah
Copy link
Contributor

admah commented Oct 13, 2023

@Cherry we have published a new version of Wrangler (3.13.1) that reverts the change that was causing issues. You should be able to update and not see this error.

@RamIdeas
Copy link
Contributor

This issue may already be fixed by #4127@Cherry can you try the prerelease build and confirm?

This issue looks unrelated to startDevWorker so I will remove the label

@RamIdeas RamIdeas removed the start-dev-worker Relating to the startDevWorker API label Oct 17, 2023
@Cherry
Copy link
Contributor Author

Cherry commented Oct 17, 2023

npx wrangler@3.13.0 dev index.ts - EBUSY error thrown on exit
npx wrangler@3.13.1 dev index.ts - exits without error
(from #4127): npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6431012321/npm-package-wrangler-4127 dev index.ts - exits without error

The issue doesn't happen in the release version of 3.13.1 though, so I'm not sure the fix at #4127 is directly related. I can reproduce the EBUSY error with 3.13.0 and running directly on C:/, not any other drive, which according to that PR shouldn't be affected.

If you have a build that includes both #4127 and #4175, I'd be happy to test that too.

@lrapoport-cf lrapoport-cf added the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Oct 18, 2023
@mrbbot
Copy link
Contributor

mrbbot commented Oct 18, 2023

Hey! 👋 We weren't able to reproduce this on Windows, but have identified something that might be causing the issue. Would you be able to try out a patch that could fix this?

$ npm install wrangler@3.13.0
$ curl https://gist.githubusercontent.com/mrbbot/3e47fda00084f8725012fa1bf37f00f2/raw/2f1193cd9cf870a790cd57bfe7f9e5395e539226/miniflare+3.20231010.0.patch > patches/miniflare+3.20231010.0.patch
$ npx patch-package
$ npx wrangler dev index.ts

@mrbbot mrbbot removed the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Oct 18, 2023
@lrapoport-cf lrapoport-cf added the awaiting reporter response Needs clarification or followup from OP label Oct 18, 2023
@Cherry
Copy link
Contributor Author

Cherry commented Oct 18, 2023

Thanks folks.

Unfortunately even with said patch applied, I'm still able to reproduce this issue every single time on my system (using 3.13.0, with patch and without), on both C: and E:

PS E:\GitHub\example-cache> npx patch-package
patch-package 8.0.0
Applying patches...
miniflare@3.20231010.0 ✔
PS E:\GitHub\example-cache> npx wrangler dev index.ts
 ⛅️ wrangler 3.13.0 (update available 3.13.2)
-------------------------------------------------------
⎔ Starting local server...
[wrangler-UserWorker:wrn] The latest compatibility date supported by the installed Cloudflare Workers Runtime is "2023-10-10",
but you've requested "2023-10-18". Falling back to "2023-10-10"...
kj/async-io-win32.c++:982: warning: Bind address resolved to multiple addresses.  Only the first address will be used.  If this is incorrect, specify the address numerically.  This may be fixed in the future.; addrs[0].toString() = 127.0.0.1:52083
[wrangler:inf] Ready on http://0.0.0.0:8787
[wrangler:inf] - http://192.168.50.240:8787
[wrangler:inf] - http://127.0.0.1:8787
[wrangler:inf] - http://172.18.64.1:8787
[wrangler:inf] - http://192.168.176.1:8787
[wrangler:inf] GET /cdn-cgi/ProxyWorker/pause 204 No Content (1ms)
[wrangler:inf] GET /cdn-cgi/ProxyWorker/pause 204 No Content (10ms)
[wrangler:inf] GET /cdn-cgi/ProxyWorker/pause 204 No Content (1ms)
[wrangler:inf] GET /cdn-cgi/ProxyWorker/play 204 No Content (1ms)
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
[MINIFLARE] Running exit hook...
E:\GitHub\example-cache\node_modules\wrangler\wrangler-dist\cli.js:29374
            throw a;
            ^

Error: EBUSY: resource busy or locked, unlink '\\?\C:\Users\james\AppData\Local\Temp\miniflare-ee302eabfa09d211dc9e4b6a95e889b2\do\-ProxyWorker\53e81e384b7316cd029cffd9d076384e77a4d545d46171275fc417e4341c7aca.sqlite-shm'
    at unlinkSync (node:fs:1883:3)
    at _unlinkSync (node:internal/fs/rimraf:214:14)
    at rimrafSync (node:internal/fs/rimraf:195:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7) {
  errno: -4082,
  syscall: 'unlink',
  code: 'EBUSY',
  path: '\\\\?\\C:\\Users\\james\\AppData\\Local\\Temp\\miniflare-ee302eabfa09d211dc9e4b6a95e889b2\\do\\-ProxyWorker\\53e81e384b7316cd029cffd9d076384e77a4d545d46171275fc417e4341c7aca.sqlite-shm'
}

If I can provide any more details to help debug this, let me know.

@lrapoport-cf lrapoport-cf added awaiting Cloudflare response Awaiting response from workers-sdk maintainer team and removed awaiting reporter response Needs clarification or followup from OP labels Oct 18, 2023
@mrbbot
Copy link
Contributor

mrbbot commented Oct 19, 2023

Thanks for trying that patch out. We've got a couple more to try! 😃

$ npm install wrangler@3.13.0
$ curl https://gist.githubusercontent.com/mrbbot/d60218708a09beddf1b667b1f73f68c8/raw/812cde2552f01d7b5ac6c385d01e5f36b43d3920/miniflare+3.20231010.0.patch > patches/miniflare+3.20231010.0.patch
$ curl https://gist.githubusercontent.com/mrbbot/d60218708a09beddf1b667b1f73f68c8/raw/812cde2552f01d7b5ac6c385d01e5f36b43d3920/wrangler+3.13.0.patch > patches/wrangler+3.13.0.patch
$ npx patch-package
$ npx wrangler dev index.ts

These should stop Wrangler using that temporary directory in the first place. We think we have a solution for the underlying problem too, but we don't really need to be writing files for these new proxy workers.

@mrbbot mrbbot added awaiting reporter response Needs clarification or followup from OP and removed awaiting Cloudflare response Awaiting response from workers-sdk maintainer team labels Oct 19, 2023
@Cherry
Copy link
Contributor Author

Cherry commented Oct 19, 2023

Thanks Brendan!

The path in the error seems slightly different now, but I am still receiving it when exiting:

patch-package 8.0.0
Applying patches...
miniflare@3.20231010.0 ✔
wrangler@3.13.0 ✔
PS E:\GitHub\example-cache>  npx wrangler dev index.ts
 ⛅️ wrangler 3.13.0 (update available 3.13.2)
-------------------------------------------------------
⎔ Starting local server...
[wrangler-UserWorker:wrn] The latest compatibility date supported by the installed Cloudflare Workers Runtime is "2023-10-10",
but you've requested "2023-10-19". Falling back to "2023-10-10"...
[wrangler:inf] Ready on http://0.0.0.0:8787
[wrangler:inf] - http://10.21.155.37:8787
[wrangler:inf] - http://192.168.50.240:8787
[wrangler:inf] - http://127.0.0.1:8787
[wrangler:inf] - http://172.30.144.1:8787
[wrangler:inf] - http://192.168.176.1:8787
kj/async-io-win32.c++:982: warning: Bind address resolved to multiple addresses.  Only the first address will be used.  If this is incorrect, specify the address numerically.  This may be fixed in the future.; addrs[0].toString() = 127.0.0.1:60689
[wrangler:inf] GET /cdn-cgi/ProxyWorker/pause 204 No Content (2ms)
[wrangler:inf] GET /cdn-cgi/ProxyWorker/pause 204 No Content (1ms)
[wrangler:inf] GET /cdn-cgi/ProxyWorker/pause 204 No Content (1ms)
[wrangler:inf] GET /cdn-cgi/ProxyWorker/play 204 No Content (1ms)
[wrangler:inf] GET / 200 OK (12ms)
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
E:\GitHub\example-cache\node_modules\wrangler\wrangler-dist\cli.js:29374
            throw a;
            ^

Error: EBUSY: resource busy or locked, rmdir '\\?\C:\Users\james\AppData\Local\Temp\miniflare-9af0de8aaf584712e630a6b34e73b4bf\do'
    at rmdirSync (node:fs:1229:10)
    at _rmdirSync (node:internal/fs/rimraf:235:5)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at Object.rmSync (node:fs:1278:10)
    at E:\GitHub\example-cache\node_modules\miniflare\dist\src\index.js:7535:27
    at process.exit (E:\GitHub\example-cache\node_modules\exit-hook\index.js:15:3) {
  errno: -4082,
  syscall: 'rmdir',
  code: 'EBUSY',
  path: '\\\\?\\C:\\Users\\james\\AppData\\Local\\Temp\\miniflare-9af0de8aaf584712e630a6b34e73b4bf\\do'
}

Node.js v18.18.0

@mrbbot
Copy link
Contributor

mrbbot commented Oct 19, 2023

Getting there! I've updated miniflare+3.20231010.0.patch. Would you be able to try...

$ npm install wrangler@3.13.0
$ curl https://gist.githubusercontent.com/mrbbot/d60218708a09beddf1b667b1f73f68c8/raw/b7ab265b79e41e802f3ce9daf6a31823c8a508d8/miniflare+3.20231010.0.patch > patches/miniflare+3.20231010.0.patch
$ curl https://gist.githubusercontent.com/mrbbot/d60218708a09beddf1b667b1f73f68c8/raw/812cde2552f01d7b5ac6c385d01e5f36b43d3920/wrangler+3.13.0.patch > patches/wrangler+3.13.0.patch
$ npx patch-package
$ npx wrangler dev index.ts

Apologies for all the back and forth 😅

@Cherry
Copy link
Contributor Author

Cherry commented Oct 20, 2023

No worries at all, happy to help!

Those most recent patches do indeed appear have to resolved it for me! 🥳 I can no longer reproduce it with those patches applied. Thanks!

@lrapoport-cf lrapoport-cf moved this from Untriaged to In Review in workers-sdk Oct 20, 2023
@lrapoport-cf lrapoport-cf removed the awaiting reporter response Needs clarification or followup from OP label Oct 20, 2023
@lrapoport-cf lrapoport-cf assigned mrbbot and RamIdeas and unassigned mrbbot Oct 20, 2023
@lrapoport-cf lrapoport-cf added the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Oct 26, 2023
@RamIdeas
Copy link
Contributor

Hey @Cherry! Can you check against the latest prerelease build of #4175? If you cannot reproduce it anymore with that build, we can close this issue 👍

@Cherry
Copy link
Contributor Author

Cherry commented Oct 26, 2023

Using the latest prerelease in that PR, I still get the EBUSY error when exiting unfortunately:

$ npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6643378589/npm-package-wrangler-4175 dev index.ts
C:\Users\james\AppData\Local\npm-cache\_npx\47a882e596518e91\node_modules\wrangler\wrangler-dist\cli.js:29374
            throw a;
            ^

Error: EBUSY: resource busy or locked, rmdir '\\?\C:\Users\james\AppData\Local\Temp\miniflare-ab0d943ffb909c7d79c41eb156a85900\cache'
    at rmdirSync (node:fs:1229:10)
    at _rmdirSync (node:internal/fs/rimraf:235:5)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at node:internal/fs/rimraf:253:9
    at Array.forEach (<anonymous>)
    at _rmdirSync (node:internal/fs/rimraf:250:7)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at Object.rmSync (node:fs:1278:10)
    at C:\Users\james\AppData\Local\npm-cache\_npx\47a882e596518e91\node_modules\miniflare\dist\src\index.js:7660:27
    at process.exit (C:\Users\james\AppData\Local\npm-cache\_npx\47a882e596518e91\node_modules\exit-hook\index.js:15:3) {
  errno: -4082,
  syscall: 'rmdir',
  code: 'EBUSY',
  path: '\\\\?\\C:\\Users\\james\\AppData\\Local\\Temp\\miniflare-ab0d943ffb909c7d79c41eb156a85900\\cache'
}

@RamIdeas
Copy link
Contributor

RamIdeas commented Nov 22, 2023

Hi @Cherry! Github got confused on that PR and the prerelease build might not have included the most recent changes. Can you try the prelease build from #4413 please? Thanks for your patience and feedback

@RamIdeas RamIdeas removed the awaiting Cloudflare response Awaiting response from workers-sdk maintainer team label Nov 22, 2023
@Cherry
Copy link
Contributor Author

Cherry commented Nov 22, 2023

I can confirm I don't get an EBUSY error with the latest prerelease in that PR, thanks @RamIdeas!

@RamIdeas
Copy link
Contributor

Hey @Cherry – thanks for confirming – can you also check your .wrangler/logs directory in your project root please?

@Cherry
Copy link
Contributor Author

Cherry commented Nov 22, 2023

Sure thing, here:

wrangler-2023-11-22_16-29-47_041.log

@RamIdeas
Copy link
Contributor

Perfect! Looks like this issue can be closed now. Thanks again for your feedback 😄

@github-project-automation github-project-automation bot moved this from In Review to Done in workers-sdk Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests

6 participants