From 5a1155b16494009f8540ea8483616b4580b1d53e Mon Sep 17 00:00:00 2001 From: Ludwig Pusl <33753999+4ludwig4@users.noreply.github.com> Date: Thu, 8 Dec 2022 08:31:18 +0100 Subject: [PATCH] CI: Move Node memory leak workaround to .npmrc file (#5622) --- .github/workflows/build-deploy.yml | 2 -- .github/workflows/codeql-analysis.yml | 2 -- .github/workflows/test.yml | 6 ++++-- .npmrc | 3 +++ docs/dev/setup.rst | 27 ++++++++++----------------- 5 files changed, 17 insertions(+), 23 deletions(-) create mode 100644 .npmrc diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 03dece47edb1..b97ebb30fcf0 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -56,8 +56,6 @@ jobs: cache: 'gradle' - name: Production Build run: ./gradlew -Pprod -Pwar clean bootWar - env: - NODE_OPTIONS: --max_old_space_size=6144 - name: Upload Artifact uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2e2ef35b4d87..a1d1a79adc54 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -76,8 +76,6 @@ jobs: # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v2 - env: - NODE_OPTIONS: --max_old_space_size=6144 - run: rm -rf build/resources/main/static diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6e15d38838e9..39259748b582 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,6 +93,10 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v3 + # It seems like there is some memory issue with these tests with the project-wide default node option + # `--max-old-space-size` set in the .npmrc, therefore we delete it for this test as a workaround + - name: remove project-wide node options set in .npmrc just for this test + run: rm .npmrc || true - name: Setup Node.js uses: actions/setup-node@v3 with: @@ -140,8 +144,6 @@ jobs: client-style: runs-on: ubuntu-latest timeout-minutes: 30 - env: - NODE_OPTIONS: '--max_old_space_size=3072' steps: - uses: actions/checkout@v3 - name: Setup Node.js diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000000..89729c8b8683 --- /dev/null +++ b/.npmrc @@ -0,0 +1,3 @@ +# project wide workaround for the webapp build which might fail due to problems regarding JavaScript heap memory leaks +node-options=--max-old-space-size=6144 + diff --git a/docs/dev/setup.rst b/docs/dev/setup.rst index e61049fc0a1d..265e7df1c37a 100644 --- a/docs/dev/setup.rst +++ b/docs/dev/setup.rst @@ -471,26 +471,19 @@ above in `Server Setup <#server-setup>`__) and if you have configured ``application-artemis.yml`` correctly, then you should be able to login with your TUM Online account. -In case you encounter any problems regarding JavaScript heap memory leaks when executing ``npm run serve`` or any other -scripts from ``package.json``, -you can add a memory limit parameter (``--max_old_space_size=5120``) in the script. -You can do it by changing the **start** script in ``package.json`` from: +.. HINT:: + In case you encounter any problems regarding JavaScript heap memory leaks when executing ``npm run serve`` or + any other scripts from ``package.json``, you can adjust a + `memory limit parameter `__ + (``node-options=--max-old-space-size=6144``) which is set by default in the project-wide `.npmrc` file. -:: - - "start": "ng serve --hmr", - -to - -:: - - "start": "node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng serve --hmr", - -If you still face the issue, you can try to set a higher value than 5120. Possible values are 6144, 7168, and 8192. + If you still face the issue, you can try to set a lower/higher value than 6144 MB. + Recommended values are 3072 (3GB), 4096 (4GB), 5120 (5GB) , 6144 (6GB), 7168 (7GB), and 8192 (8GB). -The same change could be applied to each **ng** command as in the example above. + You can override the project-wide `.npmrc` file by + `using a per-user config file (~/.npmrc) `__. -Make sure to **not commit this change** in ``package.json``. + Make sure to **not commit changes** in the project-wide ``.npmrc`` unless the Github build also needs these settings. For more information, review `Working with