Background:
We are running a NextJS site which consists of lots of microservices in tree format:
apps/app1
apps/app2 (etc etc)
...
libs/shared
libs/marketing-site
libs/otherstuff (etc etc)
Each directory has it’s own tsconfig.json and src directory.
- ALM + CI used: Bitbucket Cloud
- Scanner command:
- step: &sonarScanLibsShared
name: Sonar Scan Libs - Shared
size: 2x
caches:
- sonar
script:
- pipe: sonarsource/sonarcloud-scan:1.4.0
variables:
SONAR_SCANNER_OPTS: -Xmx256m
SONAR_TOKEN: ${SONAR_TOKEN_LIBS_SHARED}
EXTRA_ARGS: '-Dsonar.projectBaseDir=libs/shared -Dsonar.javascript.node.maxspace=7168'
The ‘active’ bit of our sonar-project.properties file is:
sonar.exclusions=**/node_modules/**,**/.storybook/**,**/.storybook/tsconfig.json,**/src/main.tsx,**/src/index.ts,**/*.min.js,**/jest.config.ts,**/*.spec.{js,jsx,ts,tsx},**/*.test.{js,jsx,ts,tsx},**/*.{story,stories}.{js,jsx,ts,tsx}
sonar.test.inclusions= **/*.spec.{js,jsx,ts,tsx},**/*.test.{js,jsx,ts,tsx},**/*.{story,stories}.{js,jsx,ts,tsx}
- Languages of the repository - NextJS / React
- Error observed:
When running sonarscan - a single file repeats and then a crash is seen most of the time - but not always - e.g:
INFO: 124/203 files analyzed, current file: /opt/atlassian/pipelines/agent/build/libs/marketing-site/util-api/src/lib/marketing-site-util-api.spec.ts
INFO: 124/203 files analyzed, current file: /opt/atlassian/pipelines/agent/build/libs/marketing-site/util-api/src/lib/marketing-site-util-api.spec.ts
ERROR: eslint-bridge Node.js process is unresponsive. This is most likely caused by process running out of memory. Consider setting sonar.javascript.node.maxspace to higher value (e.g. 4096).
ERROR: Failure during analysis, Node.js command to start eslint-bridge was: node --max-old-space-size=7168 /opt/atlassian/pipelines/agent/build/libs/marketing-site/.scannerwork/.sonartmp/eslint-bridge-bundle/package/bin/server 45083 127.0.0.1 /opt/atlassian/pipelines/agent/build/libs/marketing-site/.scannerwork true false /opt/atlassian/pipelines/agent/build/libs/marketing-site/.scannerwork/.sonartmp/eslint-bridge-bundle/package/custom-rules980193960290417194/package
java.lang.IllegalStateException: eslint-bridge is unresponsive
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:378)
But the file it “trips” on is not always the same between runs.
This looks to be a memory issue - but the codebase isn’t that big (the whole apps directory is 114 files - the whole libs directory is 1k. They’re all small files - the only one over 0.5Mb is package-lock.json.
We’ve tried targetting sections via the monorepo feature - (so the command above is for just for libs/marketing-site for example)
We’ve also given the process the max memory Bitbucket will allow (7Gb for the node space - 1Gb shared between sonarscan and the general container) - but still no dice.
Any ideas what we can do to fix it?