workers-sdk: ๐ BUG: `wrangler dev --experimental-local` slows down over time and leaks memory
What version of Wrangler are you using?
2.6.2
What operating system are you using?
Mac
Describe the Bug
If I test my simple worker with wrangler dev --experimental-local and monitor the browser devtools network tab I see that after the initial (cold) requests then next requests return in 2ms.
If I keep on refreshing the browser, I see that time slowly starts to creep up, 4ms, 6ms, 8ms, and if I keep on refreshing the browser tab a lot, it slows down to 50-70ms and keeps on slowing down further with additional http requests.
At the same time I observe that the memory usage increases from 17MB to 34MB, 50MB, 75MB, all the way to over 1GB.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 27 (14 by maintainers)
Commits related to this issue
- Temporarily use fastbuild for OS X workerd release builds The root cause of bus errors from workerd opt builds are being investigated. In the interim, use fastbuild instead. The impact of this worka... — committed to cloudflare/workerd by ohodson a year ago
- Add optimized launch and debug options in VSCode Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: https://github.com/cloudflare/workers-sdk/issues/2386 — committed to cloudflare/workerd by ohodson a year ago
- Add optimized launch and debug options in VSCode Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: https://github.com/cloudflare/workers-sdk/issues/2386 — committed to cloudflare/workerd by ohodson a year ago
- Temporarily use fastbuild for OS X workerd release builds The root cause of bus errors from workerd opt builds are being investigated. In the interim, use fastbuild instead. The impact of this worka... — committed to cloudflare/workerd by ohodson a year ago
- Add optimized launch and debug options in VSCode Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: https://github.com/cloudflare/workers-sdk/issues/2386 — committed to cloudflare/workerd by ohodson a year ago
- Add optimized launch and debug options in VS Code Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: https://github.com/cloudflare/workers-sdk/issues/2386 — committed to cloudflare/workerd by ohodson a year ago
- Temporarily use fastbuild for OS X workerd release builds The root cause of bus errors from workerd opt builds are being investigated. In the interim, use fastbuild instead. The impact of this worka... — committed to cloudflare/workerd by ohodson a year ago
- Add optimized launch and debug options in VS Code Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: https://github.com/cloudflare/workers-sdk/issues/2386 — committed to cloudflare/workerd by ohodson a year ago
- workerd: Use --single-threaded-gc Consecutive requests could lead to calling into the isolate whilst code pages are being collected. This problem has only been observed on macOS arm64. Bug: CUSTESC-... — committed to cloudflare/workerd by ohodson a year ago
- workerd: Use --single-threaded-gc Consecutive requests could lead to calling into the isolate whilst code pages are being collected. This problem has only been observed on macOS arm64. Bug: CUSTESC-... — committed to cloudflare/workerd by ohodson a year ago
- Revert "Temporarily use fastbuild for OS X workerd release builds" This reverts commit d0ac3f3317939bc78f8e5ac0e81b6df9b888aa39. The preceding commit adding --single-threaded-gc addresses the issue.... — committed to cloudflare/workerd by ohodson a year ago
- workerd: Use --single-threaded-gc Consecutive requests could lead to calling into the isolate whilst code pages are being collected. This problem has only been observed on macOS arm64. Bug: CUSTESC-... — committed to cloudflare/workerd by ohodson a year ago
- Revert "Temporarily use fastbuild for OS X workerd release builds" This reverts commit d0ac3f3317939bc78f8e5ac0e81b6df9b888aa39. The preceding commit adding --single-threaded-gc addresses the issue.... — committed to cloudflare/workerd by ohodson a year ago
- workerd: Use --single-threaded-gc Consecutive requests could lead to calling into the isolate whilst code pages are being collected. This problem has only been observed on macOS arm64. Bug: CUSTESC-... — committed to cloudflare/workerd by ohodson a year ago
- Revert "Temporarily use fastbuild for OS X workerd release builds" This reverts commit d0ac3f3317939bc78f8e5ac0e81b6df9b888aa39. The preceding commit adding --single-threaded-gc addresses the issue.... — committed to cloudflare/workerd by ohodson a year ago
- fix: register middleware once for module workers Previously, the middleware loader for module workers would register all middleware on each request. These registrations would be in addition to previo... — committed to cloudflare/workers-sdk by mrbbot a year ago
- fix: register middleware once for module workers (#3585) Previously, the middleware loader for module workers would register all middleware on each request. These registrations would be in addition... — committed to cloudflare/workers-sdk by mrbbot a year ago
- fix: register middleware once for module workers (#3585) Previously, the middleware loader for module workers would register all middleware on each request. These registrations would be in addition... — committed to cloudflare/workers-sdk by mrbbot a year ago
Iโd like to double down on this issue, as itโs currently blocking our effort to use wrangler dev in a local development / integration testing environment.
3.1.0 MacOS
For measurement I used
Bare minimum worker, no deps, no bindings
Observed Very progressive slowdown, and in the end crash
Did a control measurement with Service Worker format vs Module worker
The worker performs a lot better with
wrangler devwhen in the Service Worker format, but crashes all the same with the same error, just later (after way more requests)Iโll perform an experiment with emulated amd64 arch a bit later
Can report this is still the case in
wrangler3.0.1on MacOS.Note that this does not require the wrangler server to be used at all. It will leak just by starting it.
Command:
I also get this error after some time; Iโm not sure if itโs related to the leak.
Getting a similar issue on the latest wrangler. Donโt know if it โslows downโ but memory usage quickly goes to 10->20->30gb and it doesnโt come back down unless killed.
I was not able to verify/test because I got blocked on https://github.com/cloudflare/workers-sdk/issues/3007 which seems to suggest that
--experimental-localis currently broken in the 2.14.0 release for some if not for all users.