Typescript - JavaScript heap out of memory

Template for a good bug report, formatted with Markdown:

  • versions used
    SonarQube Version 8.9.1 (build 44547)
    SonarQube Scanner 4.2.0.1873

  • error observed

INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 4.14.246-187.474.amzn2.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 8.9.1
INFO: Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=338ms
INFO: Server id: CB92C7A1-AW43Yig0CJvDhL_u0x3r
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=170ms
INFO: Load/download plugins (done) | time=7795ms
INFO: Loaded core extensions: developer-scanner
INFO: JavaScript/TypeScript frontend is enabled
INFO: Process project properties
INFO: Process project properties (done) | time=9ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: ui.application.trackables
INFO: Base dir: /vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_src
INFO: Working dir: /vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_tmp/scannerwork
INFO: Load project settings for component key: 'ui.application.trackables'
INFO: Load project settings for component key: 'ui.application.trackables' (done) | time=146ms
INFO: Load project branches
INFO: Load project branches (done) | time=143ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=142ms
INFO: Load branch configuration
INFO: Found manual configuration of branch/PR analysis. Skipping automatic configuration.
INFO: Load branch configuration (done) | time=3ms
INFO: Auto-configuring with CI 'Bamboo'
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=170ms
INFO: Auto-configuring with CI 'Bamboo'
INFO: Load active rules
INFO: Load active rules (done) | time=5290ms
INFO: Branch name: develop
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/node_modules/**, **/libs/**, **/assets/**
INFO:   Excluded sources for coverage: **/*.spec.ts
INFO: Load project repositories
INFO: Load project repositories (done) | time=144ms
INFO: 201 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for css: VZC Way
INFO: Quality profile for ts: VZC Way
INFO: Quality profile for web: VZC Way
INFO: ------------- Run sensors on module ui.application.trackables
INFO: JavaScript/TypeScript frontend is enabled
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=141ms
INFO: Sensor CSS Metrics [cssfamily]
INFO: Sensor CSS Metrics [cssfamily] (done) | time=121ms
INFO: Sensor CSS Rules [cssfamily]
INFO: 47 source files to be analyzed
INFO: 47/47 source files have been analyzed
INFO: Sensor CSS Rules [cssfamily] (done) | time=1473ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=4ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=391ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
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
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=4ms
INFO: Sensor TypeScript analysis [javascript]
INFO: Deploying custom rules bundle jar:file:/root/.sonar/cache/1c0d0d6d358b2ff25a27998c60079e2e/sonar-securityjsfrontend-plugin.jar!/js-vulnerabilities-rules-1.0.0.tgz to /vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_tmp/scannerwork/.sonartmp/eslint-bridge-bundle/package/custom-rules18108581973766353709
INFO: Found 2 tsconfig.json file(s): [/vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_src/e2e/tsconfig.json, /vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_src/tsconfig.json]
INFO: Analyzing 153 files using tsconfig: /vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_src/tsconfig.json
INFO: 153 source files to be analyzed
INFO: 0/153 files analyzed, current file: src/app/settings/container/settings.component.spec.ts
INFO: 0/153 files analyzed, current file: src/app/settings/container/settings.component.spec.ts
ERROR: 
ERROR: <--- Last few GCs --->
ERROR: 
ERROR: [991:0x64b3f30]    25070 ms: Mark-sweep (reduce) 2046.0 (2051.8) -> 2045.7 (2053.5) MB, 1090.1 / 0.0 ms  (average mu = 0.088, current mu = 0.008) allocation failure scavenge might not succeed
ERROR: [991:0x64b3f30]    26172 ms: Mark-sweep (reduce) 2046.7 (2055.5) -> 2046.5 (2056.0) MB, 1096.1 / 0.0 ms  (average mu = 0.048, current mu = 0.005) allocation failure scavenge might not succeed
ERROR: 
ERROR: 
ERROR: <--- JS stacktrace --->
ERROR: 
ERROR: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
ERROR:  1: 0xa24ed0 node::Abort() [node]
ERROR:  2: 0x966115 node::FatalError(char const*, char const*) [node]
ERROR:  3: 0xb9acde v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
ERROR:  4: 0xb9b057 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
ERROR:  5: 0xd56ea5  [node]
ERROR:  6: 0xd57a2f  [node]
ERROR:  7: 0xd65abb v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
ERROR:  8: 0xd6967c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
ERROR:  9: 0xd37d2b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
ERROR: 10: 0x108035f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
ERROR: 11: 0x1427099  [node]
INFO: 0/153 files analyzed, current file: src/app/settings/container/settings.component.spec.ts
ERROR: Failed to get response while analyzing src/app/settings/container/settings.component.spec.ts
java.net.ConnectException: Failed to connect to /127.0.0.1:38851
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:249)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:167)
	at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
	at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
	at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:264)
	at okhttp3.RealCall.execute(RealCall.java:93)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:226)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.analyzeTypeScript(EslintBridgeServerImpl.java:217)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyze(TypeScriptSensor.java:157)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFilesWithTsConfig(TypeScriptSensor.java:145)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:126)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:125)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.execute(TypeScriptSensor.java:56)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	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(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	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.ConnectException: Connection refused (Connection refused)
	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
	at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
	at java.base/java.net.Socket.connect(Unknown Source)
	at okhttp3.internal.platform.Platform.connectSocket(Platform.java:130)
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
	... 54 common frames omitted

ERROR: Failure during analysis, Node.js command to start eslint-bridge was: node /vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_tmp/scannerwork/.sonartmp/eslint-bridge-bundle/package/bin/server 38851 127.0.0.1 /vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_tmp/scannerwork true false /vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_tmp/scannerwork/.sonartmp/eslint-bridge-bundle/package/custom-rules18108581973766353709/package
java.net.ConnectException: Failed to connect to /127.0.0.1:38851
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:249)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:167)
	at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
	at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
	at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
INFO: Sensor TypeScript analysis [javascript] (done) | time=41626ms
INFO: Sensor JavaScript/TypeScript Coverage [javascript]
INFO: Analysing [/vzc/bamboo/build-agent-home/xml-data/build-dir/CATR-UIAPTRACK-JOB1/_src/coverage/lcov.info]
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:264)
	at okhttp3.RealCall.execute(RealCall.java:93)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:226)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.analyzeTypeScript(EslintBridgeServerImpl.java:217)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyze(TypeScriptSensor.java:157)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFilesWithTsConfig(TypeScriptSensor.java:145)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.analyzeFiles(TypeScriptSensor.java:126)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:125)
	at org.sonar.plugins.javascript.eslint.TypeScriptSensor.execute(TypeScriptSensor.java:56)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	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(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	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.ConnectException: Connection refused (Connection refused)
	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
	at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
	at java.base/java.net.Socket.connect(Unknown Source)
	at okhttp3.internal.platform.Platform.connectSocket(Platform.java:130)
	at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
	... 54 common frames omitted

INFO: Sensor JavaScript/TypeScript Coverage [javascript] (done) | time=136ms
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=3ms
  • steps to reproduce
    Every analyse will recreate this issue.

  • potential workaround
    I added
    export NODE_OPTIONS="–max-old-space-size=8912"
    To my .bash_profile on the build agent where this analysis is performed. But it seem to make no difference.

Hi,

Could you try setting the heap size with sonar.javascript.node.maxspace (see the doc)?

Hi,
Can i know this maxspace set in scanner there or sonarqube server?

@johnlee : you set that parameter at scanner side.

i did set below in sonar-scanner.properties, but it seems to no avail. How to identify it’s applied?
sonar.javascript.node.maxspace=4096

Hi @johnlee,

Please create a new thread explaining your issue that prompted you to use the parameter (including logs) and it will be easier for someone to help you.

I’m managed to solve it by increasing maxspace to 6144 and upgrade the server to have more ram and CPU, thanks.

1 Like