esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

"all goroutines are asleep - deadlock!" on a build

Open amrgamal97 opened this issue 1 year ago • 13 comments

The error occurs consistently when attempting to build the Angular v17 project on the DigitalOcean server. No issues encountered when building the project locally.

steps I take:

sudo git clone https://github.com/amrgamal97/myprj.git
sudo npm install
sudo ng build

error message:

fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan receive]:
github.com/evanw/esbuild/internal/helpers.(*ThreadSafeWaitGroup).Wait(...)
        github.com/evanw/esbuild/internal/helpers/waitgroup.go:36
main.runService.func2()
        github.com/evanw/esbuild/cmd/esbuild/service.go:114 +0x59
main.runService(0x1)
        github.com/evanw/esbuild/cmd/esbuild/service.go:160 +0x4ed
main.main()
        github.com/evanw/esbuild/cmd/esbuild/main.go:240 +0xa29
Killed

Environment:


Angular CLI: 17.1.0
Node: 20.9.0
Package Manager: npm 10.1.0
OS: win32 x64

please fix it ASAP.

amrgamal97 avatar Feb 08 '24 08:02 amrgamal97

@amrgamal97 I have a seen a similar issue, though it is intermittent for me. At one point, I got it consistently, but after updating my submodules & another bun install, the error stopped. Are you using a monorepo? One possibility I'm exploring is that there are different copies of esbuild in different node_modules directories in the monorepo.

btakita avatar Feb 12 '24 05:02 btakita

We're seeing this in our project when running on Linux, it seems to happen almost every time with Node 20.11.0, and almost not at all (but still sometimes) with Node 18.19.1 or Node 20.11.1

danielrozenberg avatar Feb 21 '24 21:02 danielrozenberg

we're also seeing this in our environment:

stack trace:

fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan receive]:
github.com/evanw/esbuild/internal/helpers.(*ThreadSafeWaitGroup).Wait(...)
	github.com/evanw/esbuild/internal/helpers/waitgroup.go:36
main.runService.func2()
	github.com/evanw/esbuild/cmd/esbuild/service.go:114 +0x59
main.runService(0x1)
	github.com/evanw/esbuild/cmd/esbuild/service.go:160 +0x4ed
main.main()
	github.com/evanw/esbuild/cmd/esbuild/main.go:240 +0xa29

goroutine 18 [chan receive]:
main.runService.func1()
	github.com/evanw/esbuild/cmd/esbuild/service.go:98 +0x4a
created by main.runService
	github.com/evanw/esbuild/cmd/esbuild/service.go:97 +0x1e5

goroutine 19 [chan receive]:
main.(*serviceType).sendRequest(0xc000228030, {0x93c580, 0xc0004f7170})
	github.com/evanw/esbuild/cmd/esbuild/service.go:192 +0xfa
main.runService.func3()
	github.com/evanw/esbuild/cmd/esbuild/service.go:125 +0x39
created by main.runService
	github.com/evanw/esbuild/cmd/esbuild/service.go:122 +0x31c
Operating System: Ubuntu 20.04.6 LTS
OSType: linux

erwinmombay avatar Feb 22 '24 18:02 erwinmombay

I am also encountering the fatal error: all goroutines are asleep - deadlock! issue while using esbuild in my development environment. I am working on a Mac M1 Pro Max and facing this deadlock issue specifically when I have an Angular server running alongside multiple Node.js projects using webpack --watch. The deadlock occurs during the build process of an Angular application.

Interestingly, when I stop the Angular server and the webpack --watch processes, the build completes successfully without any errors. This seems to suggest some sort of resource contention or deadlock situation arising due to the concurrent execution of these processes.

Additionally, it's worth noting that my setup involves building the Angular application (version 17.1.3) inside a Docker container based on the node:18.17.1 image. This setup has worked well for me until I encountered this deadlock issue with esbuild.

I am looking for any guidance or suggestions on how to resolve or work around this issue. Has anyone else experienced something similar in a Dockerized environment, particularly with the mentioned versions of Node.js and Angular, on a Mac M1 Pro Max? Any insights or recommendations would be greatly appreciated.

Thank you in advance for your assistance.

csbenjamin avatar Mar 06 '24 11:03 csbenjamin

This error occurred for me around 50% of the cases when I was building our Angular project within a docker container. There was not really a pattern on when it would happen. After increasing the available memory of the docker runtime from 4GB to 8GB of RAM the error did not occur anymore.

So this deadlock might be related to the available system memory running out.

anlud avatar Mar 12 '24 07:03 anlud

https://github.com/evanw/esbuild/issues/3636#issuecomment-1990936837

This solved my issue. I was running into the same stack trace with the error.

fatal error: all goroutines are asleep - deadlock!

I was building locally on M1 pro 16GB where everything was working fine but the build was failing on VM. Upgraded VM from 4GB to 8GB RAM and it seems to be fine now

UmairMirza1 avatar Mar 13 '24 05:03 UmairMirza1

I have plenty of available memory. But it's now happening consistently on my build.

Edit: It was due to timeouts being triggered. Due to tailwind taking a very long time.

btakita avatar Apr 13 '24 06:04 btakita

I agree with btakita, i have enough memory also encountered this bug, this bug takes some time to occur.

XhstormR avatar May 02 '24 03:05 XhstormR

Thanks to a comment from @kentcdodds https://github.com/evanw/esbuild/issues/3287#issuecomment-1672026984 I was able to fix the same error in our pipelines that use playwright bdd tests after starting the angular dev server (using vite/esbuild under the hood). I added a --watch=false and deadlocks were never to be seen again.

meDavidNS avatar May 30 '24 13:05 meDavidNS