SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
37 stars 7 forks source link

PHPStan Cache Not Utilized in v3.0.1 on Mac with PHP 8.3 #57

Closed philipkozeny closed 3 months ago

philipkozeny commented 4 months ago

First of all: Thanks for the great plugin!

I've encountered an issue with PHPStan cache not being utilized while running version 3.0.1 on a Mac with PHP 8.3. It seems that every file is rechecked upon saving, leading to significant cpu spikes. This behavior is also seen at the progress bar, which indicates that all files undergo checking on each save.

When executing vendor/bin/phpstan directly from the terminal, the cache is recognized and used, resulting in a much faster process.

Could you advise on any additional information or logs that would be helpful for diagnosing this issue?

Thanks for your help.

SanderRonde commented 4 months ago

Hey thanks for the report. Could you do the following for me?

Thanks!

gglnx commented 4 months ago

I've got the same problem (but with PHP 8.1 on a M2 mac). The log:

[check:42] Check started for project
[status-bar] Showing status bar
[file-watcher] Document changed, triggering
[check:43] Check started for project
[fixer-manager] No file changes, not checking
[check:42] Check completed for project, errors= {"fileSpecificErrors":{},"notFileSpecificErrors":[]}
[check:43] Spawning PHPStan with the following configuration:  {"binStr":"/[redacted]/vendor/bin/phpstan","args":["analyse","-c","/[redacted]/phpstan.neon","--error-format=json","--no-interaction","--memory-limit=1G","-a","/[redacted]/.vscode/extensions/sanderronde.phpstan-vscode-3.0.3/_config/autoload.php","-c","/[redacted]/.vscode/extensions/sanderronde.phpstan-vscode-3.0.3/_config/config.neon"]}
[process-spawner] Spawning process 86896 with timeout 900000

The output:

$ vendor/bin/phpstan analyse -c /[redacted]/phpstan.neon --error-format=json --no-interaction --memory-limit=1G -a /[redacted]/.vscode/extensions/sanderronde.phpstan-vscode-3.0.3/_config/autoload.php -c /[redacted]/.vscode/extensions/sanderronde.phpstan-vscode-3.0.3/_config/config.neon
 396/396 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

{"totals":{"errors":1,"file_errors":0},"files":[],"errors":["<error>Child process error</error> (exit code 1): Error: Unable to encode JSON: Recursion detected\n"]}%
SanderRonde commented 4 months ago

Could you try disabling the phpstan.enableLanguageServer setting. Does it still occur then?

gglnx commented 3 months ago

Without phpstan.enableLanguageServer enabled, everything is fast and quick.

SanderRonde commented 3 months ago

Ah good to know. Then I guess my recommendation is to disable that option. It only provides on-hover information and is not actually needed for type-checking.

Going further I've disabled that option by default in the pre-release version of the extension so it'll be opt-in instead.

I'll close this issue for now, maybe I'll spend more time getting the hover-provider feature to work without busting the cache on macs but that'll be kind of hard. So for now just "disable that setting" will do.