[Bug]: service was stopped error with esbuild-wasm incorrectly loading (CI Only)
See original GitHub issueVersion
11.1.2
Steps to reproduce
https://github.com/nrwl/nx-examples/pull/209 shown in this PR since it only happens in CI.
running yarn jest --clear-cache && yarn nx run-many --target=test --all --skip-nx-cache --parallel=5
in Circle CI results in the following error.
FAIL shared-cart-state libs/shared/cart/state/src/lib/+state/cart.selectors.spec.ts ● Test suite failed to run
The service was stopped
at ../../../../node_modules/esbuild-wasm/lib/main.js:1340:29
at ../../../../node_modules/esbuild-wasm/lib/main.js:637:9
at Socket.afterClose (../../../../node_modules/esbuild-wasm/lib/main.js:615:7)
I’ve unable to reproduce locally, and every report I’ve recieved as been within a CI provider with esbuild-wasm.
Expected behavior
doesn’t run into the ‘service was stopped’ error, which seems to be linked to the esbuild-wasm being used instead of the native binary.
Test suite failed to run
The service was stopped
at ../../../../node_modules/esbuild-wasm/lib/main.js:1340:29
at ../../../../node_modules/esbuild-wasm/lib/main.js:637:9
at Socket.afterClose (../../../../node_modules/esbuild-wasm/lib/main.js:615:7)
Actual behavior
running tests from the nx-examples repo in CI (this only happens in CI 😞) results in an error saying The service was stopped
The issue seems to be present when running in parallel and using esbuild-wasm. not when running with native esbuild.
reproducing locally hasn’t had much luck, even via docker.
the error doesn’t happen when using jest
from the command line, but it still loads esbuild-wasm, which I think is at least part of the problem here, since the error only happens with esbuild-wasm.
Additional context
the service has stopped
error only appears to be happening within the context of an nx workspace under “high load” i.e. running a lot of tests in parallel, which is not unusual need from an nx workspace and not been an issue until now.
As mentioned this only appears to be happening in CI vs local environment where resources are more limited, though still happening on CI agents with 4 vCPUs and 7 GB memory, which should be plenty.
Here is an issue where I did a deeper dive into what is happening with esbuild to cause such errors. Essentually it seems that the host OS is killing the esbuild process from consuming too many resources, but I don’t have access to the sys logs on the CI machines to know for sure.
On a side note, this only happens when esbuild-wasm is running, when it’s the native binary (manually edit node_modules to force) the issue doesn’t happen and every issue reported by nx users is from esbuild-wasm being loaded instead of the native esbuild package even though there is a native binary for that host system. Systems range from various CI providers, so unsure what about the host system is saying it cannot load the native esbuild package.
A quick a dirty fix would be to allow an environment variable to override which esbuild package is being used regardless if it cannot load or not.
This is the last thing I’m trying to solve as it’s coming up in my PR for nx jest 28 support.
Happy to help debug/try stuff out if there’s anything y’all can think of. Thanks!
Environment
OS : Debian GNU/Linux 10 (buster) x64
CPUs : 2
Memory : 7GB
Node : 16.13.1
yarn : 1.22.15
nx : v14.3.6
esbuild : 0.14.11
jest : 27.5.1
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6
Top GitHub Comments
Hopefully, in angular 14 they removed the esbuild check js file so now this repo has its own check js file to ensure the fallback
Looks like it’s working. Thanks!
https://staging.nx.app/runs/hvdSCqevxqI/task/e2e-angular-extensions:e2e