Getting `ERROR: Failure when reading cache entry` with GitHub Actions but scan completes as success

  • ALM used GitHub
  • CI system used GitHub Actions
  • Scanner command used when applicable (private details masked)
    Using ubuntu-22.04 and sonarsource/sonarcloud-github-action@5875562561d22a34be0c657405578705a169af6c
  • Languages of the repository: JavaScript
  • Error observed
INFO: Sensor JavaScript inside HTML analysis [javascript]
INFO: 12 source files to be analyzed
ERROR: Failure when reading cache entry
java.io.IOException: The cache stream is too big (>2625) for file /github/workspace/.scannerwork/ucfg2/js/_Users_..._index_html.ucfgs
	at org.sonar.plugins.javascript.eslint.cache.SequenceSerialization.writeFile(SequenceSerialization.java:91)
	at org.sonar.plugins.javascript.eslint.cache.SequenceSerialization.readFromCache(SequenceSerialization.java:139)
	at org.sonar.plugins.javascript.eslint.cache.UCFGFilesSerialization.readFromCache(UCFGFilesSerialization.java:60)
	at org.sonar.plugins.javascript.eslint.cache.CacheAnalysisSerialization.readFromCache(CacheAnalysisSerialization.java:58)
	at org.sonar.plugins.javascript.eslint.cache.CacheStrategies.readFromCache(CacheStrategies.java:124)
	at org.sonar.plugins.javascript.eslint.cache.CacheStrategies.getStrategyFor(CacheStrategies.java:105)
	at org.sonar.plugins.javascript.eslint.cache.CacheStrategies.getStrategyFor(CacheStrategies.java:69)
	at org.sonar.plugins.javascript.eslint.HtmlSensor.analyze(HtmlSensor.java:93)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.analyzeFiles(AbstractEslintSensor.java:126)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:75)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
	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:470)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:466)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:422)
	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:130)
	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:57)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
	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:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	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:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
  • Steps to reproduce
    This is consistently happening when a PR triggers our pipelines

This seems similar to "java.io.IOException: The cache stream is too big" when running the scanner in our repository, but I don’t have the ability to modify the generated file that is creating the issue, and the HTML file that seems to map to does not have any lines over 100 characters long and is less than 1k total characters.

The overall run succeeds, but there are multiple errors around the cache entries.

INFO: Analysis total time: 3:26.971 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 4:07.697s
INFO: Final Memory: 664M/2220M
INFO: ------------------------------------------------------------------------

Hi,

Our general advice is to not analyze generated files.

Can you just set an exclusion for the file(s) in question?

 
Ann

From local testing, it looks like .scannerwork directory is created by Sonar. I can try adding an exclusion for it, but it seems odd that I need to exclude files generated by Sonar.

Hi,

You shouldn’t need to. It sounds like perhaps your sonar.sources definition is overly broad…?

 
Ann

The sonar.sources is set to the root of the project, but .scannerwork/ is included in the .gitignore. I’ve also tried excluding **/*.ucfgs, and I still see the same error.

This looks like it’s some kind of issue with the cache that is generated for the JS inside HTML analysis. How can I clear that cache?

Hi,

Sorry. I didn’t pay enough attention to the file path originally. We generated the file. :roll_eyes:.

I’m going to flag this for a deeper look.

 
Ann

Awesome, please keep me posted.

Hello Dan,

Many thanks for the feedback!

Those files are generated by mistake, as they shouldn’t. I created this ticket to address that issue as soon as possible.

However, these generated files don’t explain the root cause of the failure. I would need from you a minimal reproducible project example so that I can investigate further.

Thank you,
Yassin

1 Like