gilamran/tsc-watch

Be able to tweak `node` memory

Closed this issue ยท 2 comments

Description

Default node memory can be surprisingly lower I'm running tsc over the client, for an app requiring 2-3GB of RAM In rare case: some CI, some developers low-profile workstation, it crashes. Actually it even hang forever because I'm not able to catch the right info at client level but that's another topic https://github.com//issues/136 ๐Ÿ˜„

Reasons: for a same Node version but various compiled bin, memory can differ.
Here is some article about node mem https://medium.com/geekculture/node-js-default-memory-settings-3c0fe8a9ba1

How to upgrade tsc mem?

There are only 2 solutions I found:

  1. Instance tsc with node --max_old_space_size=4096 tsc ...
  2. Tweak an env variable NODE_OPTIONS=--max-old-space-size=4096
    this works for my CI, but it does not work depending your node compile bin ๐Ÿ˜ข

Issue: I can't tweak max_old_space_size with the lib

It's due to this line

const tscProcess = spawn('node', [bin, ...args]);

For instance if I add such param it works (just to try)

const tscProcess = spawn('node', ["--max_old_space_size=4096", bin, ...args]); 

RFC: fix it forever

I suggest the simple solution to just be able to tweak node mem.
We would add alternatively a way to support any node option, overkill right?

  • Just add ability to set a --maxNodeMem #### in the extractArgs method
  • Call node with --max_old_space_size= if this variable is set

If you like this solution, I will implement it.

Impact

no regression at all
(--maxMem has to be explicitely specified)

โ„น๏ธ Note I will do the PR

yea, passing parameters to node is an overkill, so yea maybe add a new option --maxNodeMem

Thank you @gilamran for such reactivity! ๐Ÿ˜ https://www.npmjs.com/package/tsc-watch/v/4.6.1