question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: service was stopped error with esbuild-wasm incorrectly loading (CI Only)

See original GitHub issue

Version

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:closed
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
ahnpnlcommented, Aug 1, 2022

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

0reactions
barbados-clemenscommented, Aug 2, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog - esbuild - Breword 文档集合
This release fixes a bug where variables declared using var inside of top-level for loop ... This problem only affected the esbuild-wasm package....
Read more >
@netlify/esbuild-android-64 | Yarn - Package Manager
This release fixes the problem by moving the "use strict" directive before the initializer for the injected file so it isn't accidentally ...
Read more >
Source - GitHub
This release fixes a bug where esbuild could in certain cases consider a name ... esbuild would incorrectly generate an error about an...
Read more >
esbuild - ng Build failing on angular 12.2.2 - Stack Overflow
I have removed the node modules like five times and re-did the npm install even with sudo but I still get the same...
Read more >
Getting Started - ESBuild
You can run the esbuild executable to verify that everything is working correctly ... for build scripts because plugins only work with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found