Sonar: sonar.javascript.node.maxspace parameter is not reflecting in the sonar scanner node execution

  • SonarQube version: 6.7.6

  • SonarScanner version: 4.5.0.2216

  • OS: Windows 10 x64

  • Java version: 11

  • Node version: 8.0.0

  • Error:

    > sonar-scanner -Dsonar.javascript.node.maxspace=5000
    INFO: Scanner configuration file: C:\Program Files\sonar-scanner-cli-4.5.0.2216-windows\sonar-scanner-4.5.0.2216-windows\bin\..\conf\sonar-scanner.properties
    INFO: Project root configuration file: C:\Users\320053825\Documents\Phoenix\source\application\web\sonar-project.properties
    INFO: SonarScanner 4.5.0.2216
    INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
    INFO: Windows 10 10.0 amd64
    INFO: User cache: C:\Users\320053825\.sonar\cache
    INFO: Scanner configuration file: C:\Program Files\sonar-scanner-cli-4.5.0.2216-windows\sonar-scanner-4.5.0.2216-windows\bin\..\conf\sonar-scanner.properties
    INFO: Project root configuration file: C:\Users\320053825\Documents\Phoenix\source\application\web\sonar-project.properties
    INFO: Analyzing on SonarQube server 6.7.6
    INFO: Default locale: "en_US", source code encoding: "UTF-8"
    INFO: Publish mode
    INFO: Load global settings
    INFO: Load global settings (done) | time=2664ms
    INFO: Server id: 64D1B4AC-AWgyG6Gf1RBpidbheTQ8
    INFO: User cache: C:\Users\320053825\.sonar\cache
    INFO: Load plugins index
    INFO: Load plugins index (done) | time=557ms
    INFO: Process project properties
    INFO: Load project repositories
    INFO: Load project repositories (done) | time=1163ms
    INFO: Execute project builders
    INFO: Execute project builders (done) | time=7ms
    INFO: Load quality profiles
    INFO: Load quality profiles (done) | time=563ms
    INFO: Load active rules
    INFO: Load active rules (done) | time=22402ms
    INFO: Load metrics repository
    INFO: Load metrics repository (done) | time=509ms
    INFO: Project key: my-phoenix-web-apps
    INFO: -------------  Scan my-phoenix-web-apps
    INFO: Load server rules
    INFO: Load server rules (done) | time=4026ms
    INFO: Base dir: C:\Users\320053825\Documents\Phoenix\source\application\web
    INFO: Working dir: C:\Users\320053825\Documents\Phoenix\source\application\web\.scannerwork
    INFO: Source paths: src
    INFO: Test paths: src
    INFO: Source encoding: UTF-8, default locale: en_US
    INFO: Index files
    INFO: Excluded sources:
    INFO:   **/node_modules/**
    INFO:   **/*.spec.ts
    INFO:   **/src/shared/shared.config.ts
    INFO:   **/*.spec.ts
    INFO: Included tests:
    INFO:   **/*.spec.ts
    INFO: 228 files indexed
    INFO: 230 files ignored because of inclusion/exclusion patterns
    INFO: Quality profile for css: Sonar way
    INFO: Quality profile for ts: Sonar way recommended
    INFO: Quality profile for web: Sonar way
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/C:/Users/320053825/.sonar/cache/1bee17e3bd3f033c19378cf80e76e18b/sonar-javascript-plugin-5.0.0.6962.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
    WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
    WARNING: All illegal access operations will be denied in a future release
    INFO: Sensor SonarCSS Metrics [cssfamily]
    INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=462ms
    INFO: Sensor SonarCSS Rules [cssfamily]
    INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=63004ms
    INFO: Sensor SonarJavaXmlFileSensor [java]
    INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=13ms
    INFO: Sensor HTML [web]
    INFO: Sensor HTML [web] (done) | time=1502ms
    INFO: Sensor Analyzer for "php.ini" files [php]
    INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=65ms
    INFO: Sensor SonarTS [typescript]
    INFO: Analyzing 89 typescript file(s) with the following configuration file C:\Users\320053825\Documents\Phoenix\source\application\web\tsconfig.json
    INFO: 1 files analyzed out of 89. Current file: C:\Users\320053825\Documents\Phoenix\source\application\web\src\adminApp\app-routing.module.ts
    INFO: 3 files analyzed out of 89. Current file: C:\Users\320053825\Documents\Phoenix\source\application\web\src\adminApp\app.module.ts
    INFO: 6 files analyzed out of 89. Current file: C:\Users\320053825\Documents\Phoenix\source\application\web\src\adminApp\models\calendar-localization.ts
    INFO: 12 files analyzed out of 89. Current file: C:\Users\320053825\Documents\Phoenix\source\application\web\src\adminApp\org\create\createorg.component.ts
    ERROR: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
    ERROR: External process `node --max-old-space-size=2048 C:\Users\320053825\Documents\Phoenix\source\application\web\.scannerwork\sonarts-bundle\node_modules\tslint-sonarts\bin\tsrunner` returned an empty output. Run with -X for more information
    INFO: Sensor SonarTS [typescript] (done) | time=238246ms
    INFO: Sensor Zero Coverage Sensor
    INFO: Sensor Zero Coverage Sensor (done) | time=65ms
    INFO: Sensor CPD Block Indexer
    INFO: Sensor CPD Block Indexer (done) | time=1ms
    INFO: 2 files had no CPD blocks
    INFO: Calculating CPD for 33 files
    INFO: CPD calculation finished
    INFO: Analysis report generated in 3547ms, dir size=1 MB
    INFO: Analysis reports compressed in 2273ms, zip size=445 KB
    INFO: Analysis report uploaded in 7877ms```
    
    
  • potential workaround: No workaround

I am trying to scan a simple angular project with around 90 typescript files, the scanner fails everytime saying the heap is out of memory. I have searched around a lot and have tried to allocate more javascript heap memory in so many places. The sonar project properties file, the sonar scanner properties file, having in line parameters when running scanner, adding NODE_OPTIONS=--max_old_space_size=xxxx in environment…Nothing seems to change the internal node call execution which always executes with node --max-old-space-size=2048 everytime…Any solutions?

hello @Alan_Cooper,

you are using 3 years old version of SonarQube, and consequently quite an old version of TypeScript analyzer. This is most likely why the option is not picked up. Updating the version to something more recent, like SonarQube 8.5 should fix the issue.