SonarCloud JavaScript/TypeScript Analysis Fails with "Bridge Server Unresponsive"

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" and sonar.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"

Hey Clara

First things first, can you bump this up to sonarsource/sonarcloud-scan:4.1.0?

For now, remove the large values you’ve set (-Dsonar.javascript.node.maxspace=18000, NODE_OPTIONS=--max_old_space_size=4096) and get back to a more vanilla state.

Hey,
I’ve bumped the version to sonarsource/sonarcloud-scan:4.1.0 as recommended, but I’m still encountering the same error.
Let me know if there’s anything else I should try. Thanks!

Here are the logs for reference:

14:51:54.688 DEBUG 'static/permissionsUI/public/index.html' generated metadata with charset 'UTF-8'
14:51:54.695 INFO  Sensor HTML [web] (done) | time=76ms
14:51:54.695 INFO  Sensor JaCoCo XML Report Importer [jacoco]
14:51:54.697 INFO  'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
14:51:54.698 INFO  No report imported, no coverage information will be imported by JaCoCo XML Report Importer
14:51:54.698 INFO  Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
14:51:54.698 INFO  Sensor Java Config Sensor [iac]
14:51:54.735 INFO  0 source files to be analyzed
14:51:54.740 INFO  0/0 source files have been analyzed
14:51:54.741 INFO  Sensor Java Config Sensor [iac] (done) | time=43ms
14:51:54.742 INFO  Sensor JavaScript/TypeScript analysis [javascript]
14:51:54.746 DEBUG Analysis of unchanged files will not be skipped (current analysis requires all files to be analyzed)
14:51:54.747 DEBUG Deploying the bridge server into /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle
14:51:54.919 DEBUG Setting deploy location to /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle
14:51:54.919 INFO  Detected os: Linux arch: amd64 alpine: false. Platform: LINUX_X64
14:51:54.920 INFO  Deploy location /opt/sonar-scanner/.sonar/js/node-runtime, tagetRuntime: /opt/sonar-scanner/.sonar/js/node-runtime/node,  version: /opt/sonar-scanner/.sonar/js/node-runtime/version.txt
14:51:54.921 DEBUG Lock acquired for extraction
14:51:54.926 DEBUG Extracting embedded node to /opt/sonar-scanner/.sonar/js/node-runtime/node
14:51:55.014 DEBUG delta [ns] since modification FileSnapshot failed to detect
count, failures, racy limit [ns], delta min [ns], delta max [ns], delta avg [ns], delta stddev [ns]
8195, 229, 8782, 2981320.0, 6790666.0, 4859435.275109173, 1089948.9475500109
14:51:55.014 DEBUG FileStoreAttributes[fsTimestampResolution=3 µs, minimalRacyInterval=6,790 µs]
14:51:55.018 DEBUG register org.eclipse.jgit.internal.storage.file.LockFile$$Lambda$717/0x00007fea7855ae48@56f14eb with shutdown hook
14:51:55.019 DEBUG unregister org.eclipse.jgit.internal.storage.file.LockFile$$Lambda$717/0x00007fea7855ae48@56f14eb from shutdown hook
14:51:55.019 DEBUG unregister org.eclipse.jgit.internal.storage.file.LockFile$$Lambda$717/0x00007fea7855ae48@56f14eb from shutdown hook
14:51:58.365 DEBUG Launching command /opt/sonar-scanner/.sonar/js/node-runtime/node -v
14:51:58.448 DEBUG Deployed node version v22.11.0
14:51:58.448 DEBUG Deploying custom rules bundle jar:file:/opt/sonar-scanner/.sonar/cache/3caedb25754ecd1b9d964bdccb38f044/sonar-securityjsfrontend-plugin.jar!/js-vulnerabilities-rules-1.0.0.tgz to /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/custom-rules13644377611302020356
14:51:58.453 DEBUG Deploying custom rules bundle jar:file:/opt/sonar-scanner/.sonar/cache/cb797b29ccfa34447c5919ebcc90b3b1/sonar-architecturejavascriptfrontend-plugin.jar!/js-architecture-frontend-1.0.0.tgz to /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/custom-rules2021707379878178701
14:51:58.480 DEBUG Starting server
14:51:58.488 DEBUG Creating Node.js process to start the bridge server on port 32849 
14:51:58.489 INFO  Using embedded Node.js runtime.
14:51:58.489 INFO  Using Node.js executable: '/opt/sonar-scanner/.sonar/js/node-runtime/node'.
14:51:58.489 DEBUG Checking Node.js version
14:51:58.489 DEBUG Launching command /opt/sonar-scanner/.sonar/js/node-runtime/node -v
14:51:58.496 DEBUG Using Node.js v22.11.0.
14:51:58.497 DEBUG Launching command /opt/sonar-scanner/.sonar/js/node-runtime/node /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs 32849 127.0.0.1 false
14:53:32.299 INFO  Memory configuration: OS (34765 MB), Node.js (4144 MB).
14:53:33.030 DEBUG Starting the bridge server
14:53:52.248 DEBUG The bridge server is listening on port 32849
14:53:52.867 DEBUG Shutting down the worker
time="2025-05-22T14:56:25Z" level=error msg="error waiting for container: unexpected EOF"

Hey Farah!

I understand that you’ve maxed out the size of your Bitbucket pipeline runner.

These users, facing the same or similar errors, specifically increased the memory available to the Docker service.

Could you give that a try? It’s also mentioned in the docs.

Hey Colin,

Thanks for the suggestion! I gave it a try (setting the Docker container memory and SONAR_SCANNER_OPTS as described), but I’m still getting errors. Here’s part of my log:

INFO  Using embedded Node.js runtime.
INFO  Using Node.js executable: '/opt/sonar-scanner/.sonar/js/node-runtime/node'.
DEBUG Using Node.js v22.11.0.
DEBUG Starting the bridge server
...
time="2025-05-29T15:25:13Z" level=error msg="error waiting for container: unexpected EOF"

I’m still hitting the “unexpected EOF” error during analysis.