-
Notifications
You must be signed in to change notification settings - Fork 131
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
Slow formatting due to module 404s #1187
Comments
EDIT: commenting out the module source attribute will fix the slowdown. The "Extension Host" output from vscode says EDIT: The slow format-on-save behaviour is still happening with the preview extension. This is super annoying!! This is also happening to me with the latest stable version of the VSCode extension. Upgrading to the preview version of the extension appears to have solved it. I still get the 404s but they don't seem to affect the formatting/saving speed. Preview extension name is "HashiCorp.terraform-preview" I'd like to see what URLs the language server is attempting to fetch, so I can try to replicate this via the command line or see whether the URL is incorrect. |
When I change the module source to a known good URL unrelated to modules, the 404 errors go away (obviously!) and the slowdown disappears. |
Thank you for raising the thorough bug report! We released the new VS Code extension 2.26.0 version (and 0.31.1 language server version) with a potential fix. So please try it and let us know if it solves this issue. |
@dbanck this is much better! Thank you! I still have the same slow experience the first time I try to save a file but afterwards it is much better. Given the caching fix it seems like that is expected? Is there anything I can do to resolve these 404s on my end? Thank you again! |
Assuming this is all related to the private Registry, i.e. modules with source = "app.terraform.io/<org-name>/..." and/or you're sourcing submodules (involving We intend to address both as part of
We are also hoping to eventually improve the performance in this area as part of #958 I hope that helps. |
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. |
Server Version
Terraform Version
Client Version
Terraform Configuration Files
Log Output
Encrypted log file: https://drive.google.com/file/d/1WtANFqHCI6CpcRFbtIpvps4-JRmJwX5A/view?usp=sharing
Expected Behavior
When I save a file it should be formatted quickly
Actual Behavior
Saving a
.tf
file takes 10+ seconds depending on how many modules are in the workspace. Even if this is a save with 0 changes in an emptytest.tf
file.Steps to Reproduce
.tf
file in a larger (more than 3 modules?) workspaceMore details
infra-terraform
with multiple nested workspaces. Workspace directories are namedterraform/<provider>/<service>
. Usually I have the entire repo opened in vscode but sometimes only one of the nested workspaces. We change and apply terraform in each of these nested workspaces. A simplified example:What I've Tried
This is an issue I've been having for months so I don't think it's a recent change. I just got around today to filing this bug because it's also experienced by others on my team. Here's some things I've already tried:
.terraformrc
and I use the plugin cache. I've restored both of these to the defaults but still have the issue..terraform
directory in all my workspaces and rerunterraform init
Log Output
From the log output it looks to me like
terraform-ls
is making some remote network calls looking for our modules and for some reason it's getting a 404. The network calls appear to block the usual formatting and other extension features that I expect. This prevents me from saving files. Sometimes this resolves after a few seconds and sometimes it times out completely after ~30 seconds. The experience is worse in our large workspaces with 20+ module calls.In the logs I see that
terraform-ls
is frequently running jobs namedOpTypeGetModuleDataFromRegistry
. I see in the code that this function eventually callsGetModuleData
and based on the errors I think this is what's failing:https://github.com/hashicorp/terraform-ls/blob/main/internal/registry/module.go#L62-L85
Whenever I open a workspace (for example our
s3
workspace in the example above) I regularly see the following error in the logs where the error count is equal to the number of module calls in the workspace. For example in our S3 workspace we call 24 modules (different buckets) and I see the following error 24 times:I hope this is enough information to pinpoint the issue. Thank you!
The text was updated successfully, but these errors were encountered: