Sonar-scanner doesn't fail in case of error

I am using SonarQube 8.2.0.32929 and have configured my build pipeline in VSTS for my angular project. When I execute npm run sonar-scanner, the sonar analysis fails, but still it reports as SUCCESSFUL and uploads the analysis to SonarQube server. This results is wrong reporting of the analysis, as it got error during analysis.

I am not bothered about the error, I want to fail the overall process and mark it as Failure, so the build pipeline can be halted. Anyway it is possible in sonar-scanner.

Below is the log extract:

2020-05-21T03:41:51.3321218Z 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).
2020-05-21T03:41:51.3321218Z ERROR: Failure during analysis, Node.js command to start eslint-bridge was: {NODE_PATH=C:\N\1\s\NWD\MyProj\node_modules\@angular-devkit\build-optimizer\node_modules} node --max-old-space-size=8192 C:\N\1\s\NWD\MyProj\.scannerwork\.sonartmp\eslint-bridge-bundle\package\bin\server 4817
2020-05-21T03:41:51.3321218Z java.lang.IllegalStateException: eslint-bridge is unresponsive
2020-05-21T03:41:51.3321218Z 	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:200)
2020-05-21T03:41:51.3321218Z 	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.analyzeTypeScript(EslintBridgeServerImpl.java:184)
2020-05-21T03:41:51.3321218Z 	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyze(TypeScriptSensor.java:153)
2020-05-21T03:41:51.3321218Z 	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFilesWithTsConfig(TypeScriptSensor.java:141)
2020-05-21T03:41:51.3321218Z 	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:121)
2020-05-21T03:41:51.3321218Z 	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:107)
2020-05-21T03:41:51.3321218Z 	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.execute(TypeScriptSensor.java:53)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
2020-05-21T03:41:51.3321218Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
2020-05-21T03:41:51.3321218Z 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:386)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:382)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:351)
2020-05-21T03:41:51.3321218Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
2020-05-21T03:41:51.3321218Z 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
2020-05-21T03:41:51.3321218Z 	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
2020-05-21T03:41:51.3321218Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
2020-05-21T03:41:51.3321218Z 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
2020-05-21T03:41:51.3321218Z 	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
2020-05-21T03:41:51.3321218Z 	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
2020-05-21T03:41:51.3321218Z 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
2020-05-21T03:41:51.3477423Z 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-05-21T03:41:51.3477423Z 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2020-05-21T03:41:51.3477423Z 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2020-05-21T03:41:51.3477423Z 	at java.lang.reflect.Method.invoke(Unknown Source)
2020-05-21T03:41:51.3477423Z 	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
2020-05-21T03:41:51.3477423Z 	at com.sun.proxy.$Proxy0.execute(Unknown Source)
2020-05-21T03:41:51.3477423Z 	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
2020-05-21T03:41:51.3477423Z 	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
2020-05-21T03:41:51.3477423Z 	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
2020-05-21T03:41:51.3477423Z 	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
2020-05-21T03:41:51.3477423Z 	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
2020-05-21T03:41:51.3477423Z Caused by: java.io.InterruptedIOException: timeout
2020-05-21T03:41:51.3477423Z 	at okhttp3.RealCall.timeoutExit(RealCall.java:108)
2020-05-21T03:41:51.3477423Z 	at okhttp3.RealCall.execute(RealCall.java:97)
2020-05-21T03:41:51.3477423Z 	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:193)
2020-05-21T03:41:51.3477423Z 	... 36 common frames omitted
2020-05-21T03:41:51.3477423Z Caused by: java.net.SocketTimeoutException: Read timed out
2020-05-21T03:41:51.3477423Z 	at java.net.SocketInputStream.socketRead0(Native Method)
2020-05-21T03:41:51.3477423Z 	at java.net.SocketInputStream.socketRead(Unknown Source)
2020-05-21T03:41:51.3477423Z 	at java.net.SocketInputStream.read(Unknown Source)
2020-05-21T03:41:51.3477423Z 	at java.net.SocketInputStream.read(Unknown Source)
2020-05-21T03:41:51.3477423Z 	at okio.Okio$2.read(Okio.java:140)
2020-05-21T03:41:51.3477423Z 	at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
2020-05-21T03:41:51.3477423Z 	at okio.RealBufferedSource.indexOf(RealBufferedSource.java:358)
2020-05-21T03:41:51.3477423Z 	at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:230)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:226)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:202)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:101)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
2020-05-21T03:41:51.3477423Z 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
2020-05-21T03:41:51.3477423Z 	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:264)
2020-05-21T03:41:51.3477423Z 	at okhttp3.RealCall.execute(RealCall.java:93)
2020-05-21T03:41:51.3477423Z 	... 37 common frames omitted
2020-05-21T03:41:51.3477423Z INFO: Sensor TypeScript analysis [javascript] (done) | time=64672ms
2020-05-21T03:41:51.3633685Z INFO: Sensor JavaXmlSensor [java]
2020-05-21T03:41:51.3633685Z INFO: Sensor JavaXmlSensor [java] (done) | time=15ms
2020-05-21T03:41:51.3633685Z INFO: Sensor HTML [web]
2020-05-21T03:42:04.5664497Z INFO: Sensor HTML [web] (done) | time=13203ms
2020-05-21T03:42:04.5664497Z INFO: Sensor SonarTS [typescript]
2020-05-21T03:42:04.5664497Z INFO: Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or later. No TypeScript analysis is performed by SonarTS.
2020-05-21T03:42:04.5664497Z INFO: Sensor SonarTS [typescript] (done) | time=0ms
2020-05-21T03:42:04.5664497Z INFO: ------------- Run sensors on project
2020-05-21T03:42:04.5976954Z INFO: Sensor Zero Coverage Sensor
2020-05-21T03:42:07.3632995Z INFO: Sensor Zero Coverage Sensor (done) | time=2766ms
2020-05-21T03:42:07.3632995Z INFO: SCM Publisher No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
2020-05-21T03:42:07.4726869Z INFO: CPD Executor 33 files had no CPD blocks
2020-05-21T03:42:07.4726869Z INFO: CPD Executor Calculating CPD for 218 files
2020-05-21T03:42:09.3320435Z INFO: CPD Executor CPD calculation finished (done) | time=1875ms
2020-05-21T03:44:38.1908140Z INFO: Analysis report generated in 80640ms, dir size=9 MB
2020-05-21T03:44:42.0032477Z INFO: Analysis report compressed in 3813ms, zip size=2 MB
2020-05-21T03:44:46.3001080Z INFO: Analysis report uploaded in 4297ms
2020-05-21T03:44:46.3157483Z INFO: ANALYSIS SUCCESSFUL, you can browse http://72.17.80.176:9000/dashboard?id=MYProj
2020-05-21T03:44:46.3313568Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2020-05-21T03:44:46.3313568Z INFO: More about the report processing at http://72.17.80.176:9000/api/ce/task?id=AXI1VVsD5_1hIsZK2Prm
2020-05-21T03:47:16.1588116Z INFO: Analysis total time: 19:29.213 s
2020-05-21T03:47:33.4400068Z INFO: ------------------------------------------------------------------------
2020-05-21T03:47:33.4400068Z INFO: EXECUTION SUCCESS
2020-05-21T03:47:33.4400068Z INFO: ------------------------------------------------------------------------
2020-05-21T03:47:33.4400068Z INFO: Total time: 20:12.401s
2020-05-21T03:47:33.5337517Z INFO: Final Memory: 12M/49M

We have the same issue. We run the VSTS SonarQube pipeline on ReactJS project.

Based on the suggestion in the error message, we tried different settings on “sonar.javascript.node.maxspace” from 2GB to 4GB, even 8GB. Our own build server has 16GB RAM. But sometimes it works, sometimes not. If it failed, we got the same error as 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)

java.lang.IllegalStateException: eslint-bridge is unresponsive

Caused by: java.net.SocketTimeoutException: Read timed out

This error won’t fail our PR build pipeline and we doubt maybe this intrenal failures will skip some code checking next and then let the PRs finish as normal.

It spent us countless time and still couldn’t figure out the good solution for it. Hope somebody could give us some good suggestions. Thanks in advance.

Hi @StephenS and @Pankaj,

Indeed our overall strategy is to not fail the whole analysis if one step if failing. And we don’t have any way to fail the analysis if some step is failing. You might consider some solutions on your side (checking error logs for example).

About the actual problem of failing TS analysis: will you be able to provide me with sources of the project having such problem (it’s possible to do it privately)? We know that for some users TS analysis sometimes fails, but so far we don’t have any understanding why.

As a troubleshooting you could try to have only typescript in your node_modules (this dependency is required for analysis) so that time is not spent on building dependencies, but no guarantee that would help.

Regards,
Elena

Thanks for the respones.

@StephenS : Same problem as mine.

@Elena : I can scan the logs as part of build pipeline, but not sure how to stop Sonar from uploading the analysis to Sonar Cube for analysis. If I can stop that from happening in any way, that would also solve the purpose. Since the reports are uploaded, the Sonar Cube analyses and publishes them and a wrong analysis report is being sent out to stakeholders on the quality of the code build.
Any way its possible in current version.

Regards,
Pankaj