Hi SonarSource Community,
I’m encountering a persistent issue with SonarCloud analysis for my TypeScript project running in Bitbucket Pipelines. Despite extensive troubleshooting and memory allocation adjustments, the analysis consistently fails with the “Bridge server is unresponsive” error, and the Bitbucket Pipeline step itself reports “Container ‘docker’ exceeded memory limit.”
Crucially, the SonarQube analysis for this same project completes successfully without any issues when run locally on a developer machine. This strongly suggests the problem is specific to the SonarCloud integration within the Bitbucket Pipelines environment and its resource management.
Environment:
- Bitbucket Pipelines Build Size:
size: 8x
(Maximum available for Bitbucket Cloud) - SonarCloud Pipe:
sonarsource/sonarcloud-scan:2.0.0
- Project Language: Primarily TypeScript/JavaScript
Problem Description: The SonarCloud analysis starts, the Node.js bridge server spins up successfully and is configured with the specified memory. However, after some time (typically during the JavaScript/TypeScript analysis phase), the analysis fails. The main Java scanner reports timeouts communicating with the bridge server, and critically, the Bitbucket Pipeline container itself (Container 'docker'
) is terminated for exceeding its memory limit (30GB for 8x
size).
I understand that 8x
is the maximum Bitbucket Pipelines size (30GB RAM). I have tried various combinations to stay within this limit:
- Current Config (latest attempt, as per my
bitbucket-pipelines.yml
):
# ... (relevant part of the pipeline config)
size: 8x
# ...
script:
- export NODE_OPTIONS=--max_old_space_size=4096 # For build steps (Jest, Forge CLI)
# ...
- pipe: sonarsource/sonarcloud-scan:2.0.0
variables:
SONAR_SCANNER_OPTS: "-Xmx6144m" # Java scanner heap
EXTRA_ARGS: '-Dsonar.sources=. -Dsonar.javascript.node.maxspace=18000 -Dsonar.verbose=true' # Node.js analysis heap
Prior attempts also included:
SONAR_SCANNER_OPTS: "-Xmx8192m"
andsonar.javascript.node.maxspace=20000
(Total 28GB allocated heap, still failed).sonar.javascript.node.maxspace=24000
(Failed, as the total allocated heap was over 30GB).
I have a comprehensive list of exclusions in my sonar-scanner.properties
to avoid scanning unnecessary files: sonar.exclusions=**/node_modules/**,**/coverage/**,**/static/**/build/**,**/*.min.js,**/*.json,**/dist/**,**/build/**,**/*.bundle.js,**/*.snap,**/*.d.ts,**/tests/**,**/*.spec.ts,**/*.test.ts,**/*.test.tsx,**/types/**
Given that 8x
is the maximum size in Bitbucket Pipelines, what are the recommended strategies for scanning very large/complex JS/TS projects that seem to require more than ~25-28GB of active memory during analysis?
Thank you for your time and assistance.
Bitbucket Logs:
at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.net.http.HttpTimeoutException: request timed out
at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:571)
at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:123)
at org.sonar.plugins.javascript.bridge.Http$JdkHttp.post(Http.java:59)
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.request(BridgeServerImpl.java:384)
... 36 common frames omitted
13:22:30.529 INFO: Hit the cache for 0 out of 0
13:22:30.655 INFO: Miss the cache for 0 out of 0
13:23:35.579 ERROR: isAlive was interrupted
java.lang.InterruptedException: null
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:386)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:553)
at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:123)
at org.sonar.plugins.javascript.bridge.Http$JdkHttp.get(Http.java:71)
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.isAlive(BridgeServerImpl.java:411)
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.heartbeat(BridgeServerImpl.java:159)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
13:23:46.769 DEBUG: Shutting down the worker
13:25:02.526 WARN: Stopping of component org.sonar.plugins.javascript.bridge.BridgeServerImpl failed
java.lang.IllegalStateException: The bridge server is unresponsive. It might be because you don't have enough memory, so please go see the troubleshooting section: https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/languages/javascript-typescript-css/#slow-or-unresponsive-analysis
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.request(BridgeServerImpl.java:387)
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.clean(BridgeServerImpl.java:514)
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.stop(BridgeServerImpl.java:545)
at org.sonar.core.platform.StartableCloseableSafeLifecyleStrategy.stop(StartableCloseableSafeLifecyleStrategy.java:38)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.stop(AbstractInjectionFactory.java:88)
at org.picocontainer.behaviors.AbstractBehavior.stop(AbstractBehavior.java:179)
at org.picocontainer.behaviors.Stored$RealComponentLifecycle.stop(Stored.java:141)
at org.picocontainer.behaviors.Stored.stop(Stored.java:118)
at org.picocontainer.DefaultPicoContainer.stopAdapters(DefaultPicoContainer.java:1048)
at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java:803)
at org.sonar.core.platform.ComponentContainer.stopComponents(ComponentContainer.java:152)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:111)
at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:414)
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:128)
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:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at jdk.proxy1/jdk.proxy1.$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:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.io.IOException: HTTP/1.1 header parser received no bytes
at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:586)
at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:123)
at org.sonar.plugins.javascript.bridge.Http$JdkHttp.post(Http.java:59)
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.request(BridgeServerImpl.java:384)
... 31 common frames omitted
Caused by: java.io.IOException: HTTP/1.1 header parser received no bytes
at java.net.http/jdk.internal.net.http.common.Utils.wrapWithExtraDetail(Utils.java:348)
at java.net.http/jdk.internal.net.http.Http1Response$HeadersReader.onReadError(Http1Response.java:675)
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.checkForErrors(Http1AsyncReceiver.java:302)
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.flush(Http1AsyncReceiver.java:268)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$LockingRestartableTask.run(SequentialScheduler.java:205)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.EOFException: EOF reached while reading
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver$Http1TubeSubscriber.onComplete(Http1AsyncReceiver.java:596)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadSubscription.signalCompletion(SocketTube.java:640)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:845)
at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:181)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:303)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:256)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:774)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:957)
at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:253)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:979)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:934)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:934)
13:25:16.045 DEBUG: Closing monitoring resources of Helm evaluator
time="2025-05-20T13:31:13Z" level=error msg="error waiting for container: unexpected EOF"