-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format on save does not work #1265
Comments
Hi @audiolomb! Sorry to hear that format on saving isn't working for you. Do you mind sharing your VS Code settings and the extension logs, so we can better identify the issue. Thanks! |
same for me, looked into extension logs and saw
|
Which Terraform version are you using? Unfortunately, the language server cannot determine the version and cannot offer formatting support without knowing it. |
Hello, I am experiencing the same issues with format on save. It will essentially hang and not complete. I am using a devcontainer as well. I have updated to TF version ** Update ** |
same problem here: |
@rd-michel are you by chance using modules hosted in a private registry? I was curious if maybe that is my issue, because I have another customer where I have a similar setup and things seem to work fine, the difference is the non-working customer we are using private registry hosted modules and the working customer, they are all local. |
The problem is with version 2.24.3. |
I unfortunately cannot confirm that the root cause is the same for everyone - even if the problem is surfaced as "formatting doesn't work". @cschar Thank you for sharing the relevant part of the log. Building on that - Can you run @dawsonar802 @audiolomb @rd-michel Can each of you look into the |
@radeksimko , I updated the extension to v2.25.0 and reproduced the issues. Below is a screenshot if it helps at all with the behavior. I made a change, saved the file, and then this window will come up for several seconds/minutes. Is there another may I can send/share the log with you vs posting it here? The log file is pretty large and has a lot to be redacted it looks like. If not, here is another screenshot which has the /formatting section: To add a bit of content, in our case anyway, we have a root module that is calling other modules. The root module is local and the other modules are hosted in a private registry. |
@dawsonar802 Thank you for sharing the log. According to that, it appears you're likely affected by hashicorp/terraform-ls#1063 where LSP requests (including the formatting ones) are delayed due to slow external network requests. Can you try commenting out any/all module calls and reproduce it? Relatedly -
That might be the reason why the metadata for those aren't available on the public registry (according to the log with 404s) - which would confirm your theory above. That said, responding with 404s should be relatively fast still. I guess the issue with blocking may still come up when there's many module calls, i.e. many HTTP requests to send and process. The API unfortunately doesn't have any kind of batching functionality, but we should of course prevent it from blocking other LSP requests.
Feel free to send it to |
Thanks @radeksimko . I sent you an email with the logfile. With regards to commenting out the modules, we have another customer we are working with that is using all local modules and using the affected versions of the extension I do not see the issues there. It is a similar setup with the same version of TF and in a devcontainer as well. I did try commenting out basically all of the resources and modules leaving only a provider block and a data block which seems to not cause any issues. I added back one module block and still did not see the issue. I would expect if more are added the issue would come up again but it seems only a few resources is not triggering it. For reference, there are ~26 (private registry) custom modules and 67 other resource blocks within this root module. |
Marking this issue as stale due to inactivity over the last 30 days. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. Thank you for understanding. |
To my knowledge this has not been fixed. I will try and confirm next week, but have just been using an earlier version of the extension until there was an update here. |
@dawsonar802 which is the last good version? |
I have been using 2.22, but 2.24.2 works as well from another post here. |
I was on version |
|
I've been having the same issue. brew installed tfenv, tried installing terraform-ls using Brew and pointing the extension to that binary, but I was getting this same error about the malformed version |
Thanks everyone, downgraded to v2.23.0 and so far so good. |
version v.2.23.0 does not work for me inside a .devcontainer. Here is my settings, any suggestions?: {
"workbench.colorTheme": "Default Dark+",
"security.workspace.trust.untrustedFiles": "open",
"files.watcherExclude": {
"**/.bloop": true,
"**/.metals": true,
"**/.ammonite": true
},
"files.autoSave": "afterDelay",
"editor.mouseWheelZoom": true,
"editor.minimap.enabled": false,
"terminal.integrated.scrollback": 100000,
"window.zoomLevel": 3,
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
},
"terminal.integrated.defaultProfile.linux": "bash",
"terraform.experimentalFeatures.validateOnSave": true,
"terraform.experimentalFeatures.prefillRequiredFields": true,
"[terraform]": {
"editor.defaultFormatter": "hashicorp.terraform",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file"
},
"[terraform-vars]": {
"editor.defaultFormatter": "hashicorp.terraform",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file"
}
} |
I've spent quite some time to come here. Any updates on this topic? |
Any of you using |
@albertorm95 This sounds like a separate topic, but in general I'd suggest upgrading to the latest version to address that. If you experience issues with that version, we can discuss those issues and get to the bottom of it. As for the original issue in the first post - We have made some improvements wrt performance in the latest version 2.26.0 as per hashicorp/terraform-ls#1258 We plan to make some more changes 🔜 as part of hashicorp/terraform-ls#1056 to help address other similar situations. There were other root causes discussed here, including missing Terraform CLI or use of wrappers or 3rd party package managers such as tfenv. We'd be happy to discuss those in a separate issue if anyone can provide details about their situation and environment. With that in mind, I'll close this issue as the initial issue (involving inaccessible Registry modules delaying formatting) was addressed. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Issue Description
Format on Save does not work
Environment Information
Terraform Information
Version: 1.2.5
Platform: windows_amd64
Outdated: true
Visual Studio Code
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
Extension Logs
The text was updated successfully, but these errors were encountered: