Closed moskoweb closed 1 year ago
This is probably a bug in Nova, there are several complains about the latest update (crashes on paste, slow on save, etc) the only thing i can recommend is to downgrade and wait for a new Nova update. Nova has done this at least 3 times since it was released.
If a new update is released and this error is still present we will investigate.
Hello,
I downgraded the version, and now it's still slow, I don't know if you updated something in the extension after updating Nova, but it really seems that it's slow to run.
The extension has not been updated in 11 months, like I mentioned earlier, Nova has introduced errors like this at least 3 times, they eventually release an update that fixes this errors.
You can make some tests if you want but from past experience i recommend you to wait for a new update.
Did you try the extension with Nova 10+?
I used it before with 10, I updated to 11.1, and that's when I opened here, I updated to 11.2, and it's still slow, I'm analyzing the logs and trying to understand what it could be, if it's something local or extension.
I disabled the Dedicated Server in the extension, and it seems to run fast, but it gives an error.
PHP CS Fixer[17:25:26.763000] Extension configuration
PHP CS Fixer[17:25:26.765000] {
"phppath": "/opt/homebrew/bin/php",
"csfixerpath": "/opt/homebrew/bin/php-cs-fixer",
"port": 8631,
"server": false,
"log": true,
"fixerv3": true,
"standard": "PSR12",
"rules": "ordered_imports: true\nno_unused_imports: true\nblank_line_after_namespace: true\nblank_line_before_statement: true\nblank_line_after_opening_tag: true\narray_syntax: { \"syntax\": \"short\" }\nconcat_space: { \"spacing\": \"one\" }\narray_indentation: true\nencoding: true\nmethod_argument_space: true\nsingle_quote: true\nspace_after_semicolon: true\noperator_linebreak: true\nconcat_space: { \"spacing\": \"one\" }\nbinary_operator_spaces:{\"default\":\"align_single_space_minimal\"}\nnot_operator_with_space:true",
"phpcsconfig": "",
"onsave": true,
"onlyiflocalconfigfile": false,
"ignoreremote": false,
"phpRespectNova": false,
"phpUseTabs": false,
"phpTabWidth": 4,
"htmltry": true,
"htmladditional": false,
"htmlrules": "preserve_newlines: true",
"twig": true,
"twigRespectNova": false,
"twigUseTabs": false,
"twigTabWidth": 4,
"twigrules": "new_line: true",
"blade": false,
"bladeRespectNova": false,
"bladeUseTabs": false,
"bladeTabWidth": 4,
"bladerules": "end_with_newline: true\nkeep_array_indentation: true\nspace_in_paren: true\nspace_in_empty_paren: true\nunescape_strings: true",
"phpcsfixerVersion": "3.4.0"
}
PHP CS Fixer[17:25:26.773000] The file does not contain HTML, skip HTML formatting
PHP CS Fixer[17:25:26.782000] temp file created in
PHP CS Fixer[17:25:26.782000] /Users/alanmosko/Library/Application Support/Nova/Workspaces/4BA50F2A-DDCE-404D-8A83-0197C1CD1887/biati.phpcsfixer/apphttpcontrollersapiwhatsappapisalmancontroller.php
PHP CS Fixer[17:25:26.785000] Using existing cache file
PHP CS Fixer[17:25:26.785000] Cache file path is /Users/alanmosko/Library/Application Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache
PHP CS Fixer[17:25:26.789000] Additional user rules
PHP CS Fixer[17:25:26.791000] {
"ordered_imports": true,
"no_unused_imports": true,
"blank_line_after_namespace": true,
"blank_line_before_statement": true,
"blank_line_after_opening_tag": true,
"array_syntax": {
"syntax": "short"
},
"concat_space": {
"spacing": "one"
},
"array_indentation": true,
"encoding": true,
"method_argument_space": true,
"single_quote": true,
"space_after_semicolon": true,
"operator_linebreak": true,
"binary_operator_spaces": {
"default": "align_single_space_minimal"
},
"not_operator_with_space": true
}
PHP CS Fixer[17:25:26.792000] Generated command to fix file
PHP CS Fixer[17:25:26.793000] /opt/homebrew/bin/php /opt/homebrew/bin/php-cs-fixer fix /Users/alanmosko/Library/Application Support/Nova/Workspaces/4BA50F2A-DDCE-404D-8A83-0197C1CD1887/biati.phpcsfixer/apphttpcontrollersapiwhatsappapisalmancontroller.php --rules={"@PSR12":true,"ordered_imports":true,"no_unused_imports":true,"blank_line_after_namespace":true,"blank_line_before_statement":true,"blank_line_after_opening_tag":true,"array_syntax":{"syntax":"short"},"concat_space":{"spacing":"one"},"array_indentation":true,"encoding":true,"method_argument_space":true,"single_quote":true,"space_after_semicolon":true,"operator_linebreak":true,"binary_operator_spaces":{"default":"align_single_space_minimal"},"not_operator_with_space":true} --using-cache=yes --cache-file=/Users/alanmosko/Library/Application Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache
PHP CS Fixer[17:25:26.802000] Calling PHP Formatting using a process
PHP CS Fixer[17:25:27.421000] PHP formatted in process took 628ms
PHP CS Fixer[17:25:27.421000] 1) /Users/alanmosko/Library/Application Support/Nova/Workspaces/4BA50F2A-DDCE-404D-8A83-0197C1CD1887/biati.phpcsfixer/apphttpcontrollersapiwhatsappapisalmancontroller.php
Fixed 1 of 1 files in 0.355 seconds, 20.000 MB memory used
PHP CS Fixer[17:25:27.421000] Formatting process error
PHP CS Fixer[17:25:27.421000] Loaded config default.
Using cache file "/Users/alanmosko/Library/Application Support/Nova/Extensions/biati.phpcsfixer/php/.php-cs-fixer.cache".
I see that you are using a custom path for phpcsfixer, that can also be the problem, try removing your custom fixer and make some tests.
Yes, I use the custom one, because since I installed the extension, the default plugin option has never worked, it always gives me an error.
I did a new test, and it seems that the training response time is fast, but what is being slow is the extension time to rewrite the file.
I took the command that runs in the log, and changed the file path created by the extension to the real file path, and the formation was immediate:
php-cs-fixer fix **[REAL_PATH_FILE]** --rules='{"@PSR12":true,"ordered_imports":true,"no_unused_imports":true,"blank_line_after_namespace":true,"blank_line_before_statement":true,"blank_line_after_opening_tag":true,"array_syntax":{"syntax":"short"},"concat_space":{"spacing":"one"},"array_indentation":true,"encoding":true,"method_argument_space":true,"single_quote":true,"space_after_semicolon":true,"operator_linebreak":true,"binary_operator_spaces":{"default":"align_single_space_minimal"},"not_operator_with_space":true}' --using-cache=yes
Loaded config default.
Using cache file ".php-cs-fixer.cache".
1) .../MyFile.php
Fixed 1 of 1 files in 0.393 seconds, 22.000 MB memory used
And I also noticed that when I disable the function of using the dedicated server, the command is executed, completed successfully, but returns an error:
I made the modification below locally, and it solved the problem of slow running without the dedicated server. It may be that the problem with the server is similar.
https://github.com/biati-digital/nova-php-cs-fixer/compare/main...moskoweb:nova-php-cs-fixer:patch-1
I did a new test, and it seems that the training response time is fast, but what is being slow is the extension time to rewrite the file.
The extension does not rewrite the file, it only formats the code and then it gives the output to Nova, Nova is the one that updates the file, restores scroll position, etc.
I made the modification below locally, and it solved the problem of slow running without the dedicated server. It may be that the problem with the server is similar.
I'm not exactly sure how your change would solve a slowness problem, your change will add support for newer versions of php-cs-fixer as they have changed the output but in your screenshot it shows that it took the process 536ms to format the code, that's really fast, then it returns an error because the extension it's expecting the output to contain "Fixed all files" but newer versions of php-cs-fixer changed that.
Did you test the dedicated server option after your change?
I'll merger your PR but it would be great if we make sure the dedicated server option works correctly, there's been cases where users have better results with the dedicated server option, even in an old version of the extension i removed the "dedicated server" option to simply run the process using Nova and there were several complains from users so i had to add it again, i think it depends a lot on the user config, php version, php-cs-fixer, etc.
Due to the continuous slow server, it seems to me that it is waiting for the result but it takes a while to receive the result, even finishing the process of formatting the file.
It could be that Nova has changed the way it returns the NovaJSFetchResponse object, I don't know, assumption.
Why when I deactivate the server, it is almost instantaneous the execution of PHP CS Fixer, while with the server it seems that it stays up to 60 seconds and timeout.
It seems something changed, i currently have a lot of work so can not check the server option, i'll include your fix and set the option "PHP dedicated server" to false by default.
Thank's for taking a look at this.
Mac OS Version MacBook Air M2, 2022 Ventura 13.3.1 (a) (22E772610a)
PHP version PHP 8.2.6
Nova version 11.1
Describe the bug After updating to the latest version of Nova, when saving and processing PHP CS Fixer, page validation and formatting were very slow, taking almost a minute to complete the task.
Extension Debug output (REQUIRED)