-
Notifications
You must be signed in to change notification settings - Fork 61
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
Skip checking for updates for completion commands #554
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me but I don't think it will fix your issue with the error:
'there was a problem updating the versioning information...'
Because that error looks to come from a separate call to load the config here:
Lines 133 to 165 in 2306872
// Validate if configuration is older than its TTL | |
if check.Stale(file.CLI.LastChecked, file.CLI.TTL) { | |
if verboseOutput { | |
text.Info(out, ` | |
Compatibility and versioning information for the Fastly CLI is being updated in the background. The updated data will be used next time you execute a fastly command. | |
`) | |
} | |
wait = true | |
go func() { | |
// NOTE: we no longer use the hardcoded config.RemoteEndpoint constant. | |
// Instead we rely on the values inside of the application | |
// configuration file to determine where to load the config from. | |
err := file.Load(file.CLI.RemoteConfig, config.FilePath, httpClient) | |
if err != nil { | |
// If there is an error loading the configuration, then there is no | |
// point trying to retry the operation on the next CLI invocation as we | |
// already have a static backup that can be used. Defer another attempt | |
// until after the TTL has expired. | |
file.CLI.LastChecked = time.Now().Format(time.RFC3339) | |
file.Write(config.FilePath) | |
errNotice := "there was a problem updating the versioning information for the Fastly CLI" | |
checkAgain := fmt.Sprintf("we won't check again until %s have passed", file.CLI.TTL) | |
errLoadConfig = fsterr.RemediationError{ | |
Inner: fmt.Errorf("%s (%s):\n\n%w", errNotice, checkAgain, err), | |
Remediation: fsterr.BugRemediation + "\n\n" + fsterr.ConfigRemediation, | |
} | |
} | |
waitForWrite <- true | |
}() | |
} |
Weird I didn't see the contents of |
Nope. I don't think having the config would be useful so we should try to avoid it when handling the shell autocomplete command. That said, the logic for checking whether the config is stale is happening in So you could go big and refactor the main func so that the stale check is moved into the run func, or maybe because we're only checking for a single flag, |
c16be6f
to
f7be6c3
Compare
I was able to reproduce the latency and error output by installing the Network Link Conditioner tooling from Apple. I made an "Extremely Bad Network" configuration to test out this functionality: In order to properly test this, one must override the Using this technique, I arrived at the latest commit: f7be6c3 |
// NOTE: We don't want to trigger a config check when the user is making an | ||
// autocomplete request because this can add additional latency to the user's | ||
// shell loading completely. | ||
if check.Stale(file.CLI.LastChecked, file.CLI.TTL) && !cmd.IsCompletion(args) && !cmd.IsCompletionScript(args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nice, I forgot I had moved that stuff into a separate package 🙂
I have my shell (ZSH) configured to support completion of
fastly
CLI commands. To do this, I have placed the following into my ~/.zshrc:When on high-latency internet connections, the asynchronous update check adds 3 seconds to the loading of my shell. Furthermore, because the check fails with such spotty internet, I see the following message before my shell prompt following the 3 second timeout:
Instead of filing a bug, I thought I'd try to fix it myself.
I'm not sure if this actually works because I can't build the source code given my spotty airplane wi-fi.