Hi,
We are trying to set up our React project in SonarCloud and I am having issues with the scan timing out. Any help would be greatly appreciated.
ALM used - Bitbucket Cloud
CI system used - Bitbucket Cloud
Scanner command used when applicable (private details masked) - Below
Languages of the repository - React
This is the pipeline configuration I am running in order to do the scan:
step_def6: &build_react_sonar
name: Build React Sonar
image: rfsmartproducts/dotnet-node-and-jdk11:1
caches:
- node-custom
script:
- yarn install
- yarn test --coverage .
- node BitBucketTestCoverageReporter.js
- pipe: sonarsource/sonarcloud-scan:1.4.0
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
SONAR_SCANNER_OPTS: -Xmx4096m
EXTRA_ARGS: '-Dsonar.projectKey=<ProjectKey>
-Dsonar.organization=<Organization>
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.login="${SONAR_TOKEN}"
-Dsonar.language="js,jsx,ts,tsx"
-Dsonar.sources=src/
-Dsonar.exclusions="src/**/tests/**/*,node_modules/**,src/semantic-ui/**,src/test-utils/**"
-Dsonar.tests=src/
-Dsonar.test.inclusions="src/**/tests/**"
-Dsonar.typescript.lcov.reportPaths=./coverage/lcov.info
-Dsonar.javascript.node.maxspace=4096'
artifacts:
- ClientApp/build/**
- ClientApp/configs/**
- ClientApp/coverage/lcov-report/**
When running the pipeline, it gets to the point where it is analyzing the files, but gets stuck and eventually times out. I have tried increasing the memory, but it has not given me a successful scan.
It gets to this part where it is analyzing the files and takes an extremely long time, outputting a new line for the same current file every minute or so.
INFO: 532 source files to be analyzed
INFO: 0/532 files analyzed, current file: /opt/atlassian/pipelines/agent/build/<app path>/ClientApp/src/components/layout/CollapsibleBox.tsx
INFO: 0/532 files analyzed, current file: /opt/atlassian/pipelines/agent/build/<app path>/ClientApp/src/components/layout/CollapsibleBox.tsx
...
INFO: 0/532 files analyzed, current file: /opt/atlassian/pipelines/agent/build/<app path>/ClientApp/src/components/layout/CollapsibleBox.tsx
INFO: 0/532 files analyzed, current file: /opt/atlassian/pipelines/agent/build/<app path>/ClientApp/src/components/layout/CollapsibleBox.tsx
I then sometimes get an error, which I have already set in the pipeline above:
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).
Eventually, the entire build times out:
ERROR: Failure during analysis, Node.js command to start eslint-bridge was: node --max-old-space-size=4096 /opt/atlassian/pipelines/agent/build/Rfsmart.Shipping.Web/ClientApp/.scannerwork/.sonartmp/eslint-bridge-bundle/package/bin/server 33425 127.0.0.1 /opt/atlassian/pipelines/agent/build/Rfsmart.Shipping.Web/ClientApp/.scannerwork true false /opt/atlassian/pipelines/agent/build/Rfsmart.Shipping.Web/ClientApp/.scannerwork/.sonartmp/eslint-bridge-bundle/package/custom-rules11362847958499835463/package
java.lang.IllegalStateException: eslint-bridge is unresponsive
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:378)
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.createProgram(EslintBridgeServerImpl.java:462)
at org.sonar.plugins.javascript.eslint.AnalysisWithProgram.analyzeFiles(AnalysisWithProgram.java:79)
at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:98)
at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:73)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:468)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:464)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:420)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.net.http.HttpTimeoutException: request timed out
at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:559)
at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:119)
at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:369)
... 34 common frames omitted