swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.69k stars 69 forks source link

Potential Memory Leak with ESM in Node v20.0.0 #712

Closed arimgibson closed 3 months ago

arimgibson commented 1 year ago

Repro: https://github.com/arimgibson/swc-node-esm-memory-leak

Happens only when running Node v20.0.0 and is almost certainly due to breaking changes for custom ESM loaders introduced in Node v20. Links and context available in repro.

This is the only running Node process, and it can climb higher if given enough time (i.e. increase setTimeout delay) image

yeliex commented 4 months ago

it seems a bug of experimental-loader. use node --import @swc-node/register/esm-register script.ts instead as experimental-loader has been deprecated

arimgibson commented 3 months ago

node --import @swc-node/register/esm-register script.ts

Yep, seems like it works now. Pretty sure I created this issue right when v20 launched and it was still experimental. Or something like that... anyways, thanks @yeliex !