We have sonarCloud configured for our nx monorepo (sonar.typescript.tsconfigPath is pointing to tsconfig in the monorepo root)
We trigger the scan via our GitHub actions workflow using the action: SonarSource/sonarcloud-github-action@master.
Until a few days ago our setup was working as expected, we are now experiencing a huge performance degradation:
scans on PR (one line modified) takes hrs - the scan tries to analyse more then 5k files and the analysis for each files takes up to 5 seconds.
we noticed that the JavaScript/TypeScript/CSS Code Quality and Security plugin version in use has changed since our last performant scan (version in use is now: 10.3.1.21905).
our sonarCloud cache is enabled, but it looks that none of the 5k files that the scan is trying to analyse is retrieved from the cache.
Is the analysis logic changed in the last version of the package so that our cache has been invalidated or that our configuration is somehow not optimal anymore?
Could you guys suggest some paths for investigation?
indeed cache is invalidated on each new JS/TS analyzer release. So it’s normal that the first scan will take longer.
Can you please enable debug logs (-X option) and paste here the logs? If you can provide them with and without the sonar.typescript.tsconfigPath that would help us better understand if the tsconfig resolution is affecting your results.
Hey Victor,
thank you so much for your quick reply. I’ll produce the needed logs (partial - analysis does not look to complete even after hours that is running). Is there a way to send them to you privately?
Hi, we’ve encountered a similar issue, started for us about 6pm on Friday UK time. What used to take 2 minutes now takes 45 minutes.
We enabled debug logs and noted that the sonar-scanner-cli is downloading plugins from https://sonarcloud.io/api/plugins/installed. In particular it’s installing “JavaScript/TypeScript/CSS Code Quality and Security” plugin (10.3.1 (build 21905)) which was updated at 1686939214766 Fri Jun 16 2023 18:13:34.
We’ve also notice that the analyze step in the scan is taking much longer than it used
INFO: Sensor JavaScript/TypeScript analysis [javascript]
INFO: 2242 source files to be analyzed
When it was running fast we noticed that the log indicate that it found tsconfig files and was “Creating TypeScript program”. Now it is running slow we don’t see these log messages,
Many thanks and if there is anything else I can try, to gather more information, I’ll be happy to help,
thanks for your feedback. Indeed last changes seems to have affected projects with several tsconfigs. Can you please confirm that’s your case? One workaround until we provide a fix is to provide the sonar property sonar.typescript.tsconfigPath pointing to the base tsconfig in the project root. Let me know if that helps in your case.
About the logs, if you enable debug logs (-X) you will see that the analyzer is still finding the tsconfig files, it’s just following a different strategy assigning them to each source file.
Hello Victor,
thanks a lot for your help: having a sonar.typescript.tsconfigPath pointing to the a tsconfig in the monorepo root that includes all files fixes the issue for us.
We work with an Nx monorepo with Angular and Qwik apps, if we can help further narrowing down the issue just let us know.
I am having this same issue, my repo used to take 2 minutes, now 50 mins and I have even less files than ianhomer, we only have 1344 files.
I have set the base tsconfig on the root of our monorepo but no change on slow run of analysis.
thanks for the feedback. Are you using the sonar.typescript.tsconfigPath to point to the base tsconfig? Can you share the contents of that tsconfig? You can send them privately if you prefer.
We’re React, node back end, with npm workspaces. We have about 20 tsconfig files. 1 in root and then others in package sub directories. We also have a few alternative names for tsconfigs, e.g. tsconfig.test.json.
We’ve not noticed any side effects (yet) from using the root tsconfig for the scanning, all been working well for the last day or so.