aura-nw / moleculer-ts-base

Base project for all moleculer project in aura
6 stars 0 forks source link

Crash (SIGSEGV) when running test #2

Open tuanbass opened 1 year ago

tuanbass commented 1 year ago

When running test require VM module (knex for sample), sometime jest is crashed.

tuanbass commented 1 year ago

It's caused by an open issue in node:

https://github.com/nodejs/node/issues/35889 actually the problem in V8 js engine https://bugs.chromium.org/p/chromium/issues/detail?id=1238312

Cause: when running test suites, jest try to isolate the running environment for each suite. to do so, it uses VM from nodejs (actually Chrome V8 js engine). However, the VM module is experiment and contains a crash bug (which openned for ~ 2 years). See detail in the above link.

Proposal: Use another Jest runner just does not use VM module. Impact: Suite isolation must be cared by the dev

Something not supported by jest-light-runner

tuanbass commented 1 year ago

In case of switch back to CJS, there are some toys used to convert 3rd party lib which support only esm to cjs

https://www.reddit.com/r/javascript/comments/wrl0n6/tired_of_your_favorite_packages_being_esmonly_i/

tuanbass commented 1 year ago

Workaround could be: Using runner: 'jest-light-runner',

Impact:

tuanbass commented 1 year ago

Fixed in commit https://github.com/aura-nw/moleculer-ts-base/commit/aadaa6cd9e6098c572f54e35dc326a137917f214

I will have this issue opened to track the upstream issue with jest and V8 above

tuanbass commented 1 year ago

few other solution to try:

https://gist.github.com/rstacruz/511f43265de4939f6ca729a3df7b001c