Hello SonarCloud Community,
We are experiencing an issue where our SonarCloud analysis step in Bitbucket Pipelines hangs indefinitely. We would appreciate any help or insights you could provide.
Technical Details:
- ALM: Bitbucket Cloud
- CI System: Bitbucket Cloud Pipelines
- Initially observed on self-hosted Bitbucket Runners (Kubernetes).
- Issue persists when using standard Bitbucket Cloud runners (tested with up to 16x resources).
- Scanner Used: Bitbucket Pipe
sonarsource/sonarcloud-scan:4.1.0
- Languages of Repository: JavaScript/TypeScript (Node.js, Angular project)
Bitbucket Pipelines Configuration (bitbucket-pipelines.yml
):
pipelines:
pull-requests:
'**':
- step: &sonarcloud
name: SonarCloud analysis
size: 16x
script:
- pipe: sonarsource/sonarcloud-scan:4.1.0
variables:
SONAR_TOKEN: $SONAR_TOKEN
EXTRA_ARGS: >
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=vega-workspace-01
-Dsonar.projectKey=Vega_Workspace_01_nebula-ews
-Dsonar.sources=.
-Dsonar.projectBaseDir=$BITBUCKET_CLONE_DIR
-Dsonar.scm.exclusions.disabled=true
-Dsonar.log.level=DEBUG
-Dsonar.verbose=true
- pipe: sonarsource/sonarcloud-quality-gate:0.2.0
variables:
SONAR_TOKEN: $SONAR_TOKEN
Error Observed:
The SonarCloud scan starts correctly, downloads necessary components (JRE, engine, plugins), loads settings and rules, but then hangs indefinitely after attempting to start the Node.js bridge server. The logs show the following messages, and then nothing further happens, even after waiting for 15+ minutes:
[...]
09:35:57.531 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
09:35:57.532 DEBUG Lock acquired for extraction
09:35:57.537 DEBUG Extracting embedded node to /opt/sonar-scanner/.sonar/js/node-runtime/node
[...]
09:36:00.745 DEBUG Launching command /opt/sonar-scanner/.sonar/js/node-runtime/node -v
09:36:00.822 DEBUG Deployed node version v22.11.0
09:36:00.823 DEBUG Deploying custom rules bundle jar:file:/opt/sonar-scanner/.sonar/cache/56b4a307bec65b3532a905e4b5b5fa58/sonar-securityjsfrontend-plugin.jar!/js-vulnerabilities-rules-1.0.0.tgz to /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/custom-rules7907442354314246245
09:36:00.827 DEBUG Deploying custom rules bundle jar:file:/opt/sonar-scanner/.sonar/cache/e84307d9f4320d1fccef426dd326ef62/sonar-architecturejavascriptfrontend-plugin.jar!/js-architecture-frontend-1.0.0.tgz to /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/custom-rules1995873229169027105
09:36:00.864 DEBUG Starting server
09:36:00.871 DEBUG Creating Node.js process to start the bridge server on port 45621
09:36:00.872 INFO Using embedded Node.js runtime.
09:36:00.872 INFO Using Node.js executable: '/opt/sonar-scanner/.sonar/js/node-runtime/node'.
09:36:00.872 DEBUG Checking Node.js version
09:36:00.872 DEBUG Launching command /opt/sonar-scanner/.sonar/js/node-runtime/node -v
09:36:00.882 DEBUG Using Node.js v22.11.0.
09:36:00.882 DEBUG Launching command /opt/sonar-scanner/.sonar/js/node-runtime/node /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs 45621 127.0.0.1 false
<--- HANGS HERE INDEFINITELY OR FAILS--->
After hanging at this point for approximately 5 minutes (300 seconds), the process eventually fails with the following timeout error:
10:00:17.748 ERROR Failed to start the bridge server (300s timeout)
org.sonar.plugins.javascript.nodejs.NodeCommandException: Failed to start the bridge server (300s timeout)
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.startServer(BridgeServerImpl.java:228)
at org.sonar.plugins.javascript.bridge.BridgeServerImpl.startServerLazily(BridgeServerImpl.java:326)
at org.sonar.plugins.javascript.analysis.AbstractBridgeSensor.execute(AbstractBridgeSensor.java:69)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:63)
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:190)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:186)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:157)
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.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.scanner.bootstrap.ScannerMain.runScannerEngine(ScannerMain.java:137)
at org.sonar.scanner.bootstrap.ScannerMain.run(ScannerMain.java:52)
at org.sonar.scanner.bootstrap.ScannerMain.main(ScannerMain.java:38)
Additional Context & Troubleshooting:
- This analysis was previously working correctly and stopped working suddenly without any known changes to the
bitbucket-pipelines.yml
configuration or the SonarCloud project settings. - We initially suspected an issue with our self-hosted Kubernetes runners (network, infrastructure).
- We then tested using standard Bitbucket Cloud runners. With default resources (
size: 1x
, 4GB), the process sometimes failed with memory errors. Increasing resources to the maximum (size: 4x
, 16GB) resolved the memory errors, but the hang persists at the same point (launching the Node.js bridge server). - The project is a relatively small Angular application. The build step itself (if run separately) completes quickly (around 1 minute 40 seconds) using significantly fewer resources.
- We have confirmed the
SONAR_TOKEN
is correctly configured and has the necessary permissions. - Network connectivity from the runner to
sonarcloud.io
andscanner.sonarcloud.io
seems fine, as evidenced by the successful download of JRE, engine, and plugins earlier in the logs.
Steps to Reproduce:
- Configure a Bitbucket Pipeline using the
sonarsource/sonarcloud-scan:4.1.0
pipe as shown above for the specified project. - Ensure
DEBUG
logging is enabled (-Dsonar.log.level=DEBUG -Dsonar.verbose=true
). - Trigger the pipeline (e.g., by pushing to a branch or creating/updating a PR, depending on the pipeline trigger).
- Observe the logs for the
SonarCloud analysis
step. - The process hangs after the
Launching command ... server.cjs ...
log line.
Potential Workaround:
We have not found any workaround yet.
Could this be related to the specific version of the embedded Node.js (v22.11.0
according to logs) used by the scanner, an issue within the sonarcloud-scan:4.1.0
pipe interacting with the Bitbucket environment, or a potential network block specifically affecting the Node.js server process?
Thank you for your time and assistance.
Felipe Rodriguez