micro-wakatime icon indicating copy to clipboard operation
micro-wakatime copied to clipboard

checking for cli updates slows down micro startup

Open RaphyJake opened this issue 5 years ago • 2 comments

the checkCli() call in the init() function takes about two seconds on my machine:

2021/03/18 12:46:31 Micro started
2021/03/18 12:46:31 initializing WakaTime v1.0.3
2021/03/18 12:46:31 Current wakatime-cli version is 13.0.7

2021/03/18 12:46:31 Checking for updates to wakatime-cli...
2021/03/18 12:46:33 wakatime-cli is up to date
2021/03/18 12:46:33 WakaTime initialized

This is reasonable, my internet connection is not one of the best. Still, since in these two seconds I can't use micro (and I tend to open / close micro a lot) I was wondering if there was some way to make micro instantly usable, for instance by doing the update-checking part concurrently (at the risk of losing a few keystrokes if you start typing with an outdated wakatime cli)

micro version:

Version: 2.0.9-dev.52
Commit hash: 6f949fe9
Compiled on March 18, 2021

RaphyJake avatar Mar 18 '21 12:03 RaphyJake

Unfortunately there's no fnacy way to start threads in Lua (which is the plugins' language). By this reason at this time we need to wait for checkCli() to finish execution before actually opening the terminal. Also in micro everything seems to be run synchronous.

gandarez avatar Mar 18 '21 19:03 gandarez

Unfortunately there's no fnacy way to start threads in Lua (which is the plugins' language). By this reason at this time we need to wait for checkCli() to finish execution before actually opening the terminal. Also in micro everything seems to be run synchronous.

Regardless of whether this is fixable right now, this is still a pretty ridiculous downside to the plugin and needs to either be addressed or be given proper notice on the README. I decidedly won't be using this plugin due to the insane delay.

Here's a solution: Remembering the last time a check was made, and then not making a request for a week or at least a day later. Or caching the S3 bucket response, however you'd like to go about it.

In my opinion, update checking should be made part of the CLI itself, and not offloaded to the plugin to check.

A 2 second delay for using Micro is UNACCEPTABLE. This issue is not resolved.

Xevion avatar Jan 02 '23 09:01 Xevion