withfig / fig

Public issue tracker for Fig.
https://fig.io
MIT License
2.05k stars 63 forks source link

Autocomplete stops working when mac is offline #701

Closed yurakruhlyk closed 2 years ago

yurakruhlyk commented 2 years ago

Sanity checks

Issue Details

Description:

When mac just reloaded or comes out of sleep, sometimes fig autocomplete just stops working. And it looks like this issue about internet connection because when I got the issue again and opened debug console I saw that some modules didn't load. After off/on to autocomplete in fig menu we got new logs in the console and everything works fine. So I think probably the module doesn't have time to load and do this before mac is online.

Screenshot 2021-12-14 at 19 55 49 Screenshot 2021-12-14 at 20 07 12 Screenshot 2021-12-14 at 20 07 23

terminal: iTerm2 3.4.14 OS: macOS Monterey 12.0.1 (M1 Pro, 14-inch)

Environment

Fig Version: Version 1.0.53 (B339) [Debug] [U.S.]
UserShell: /bin/zsh
Bundle path: /Applications/Fig.app
Autocomplete: true
Settings.json: true
CLI installed: true
CLI tool path: /Users/user/.fig/bin/fig
Accessibility: true
Number of specs: 0
SSH Integration: false
Tmux Integration: false
Keybindings path: <none>
iTerm Integration: installed!
Hyper Integration: application is not present.
VSCode Integration: installed!
Docker Integration: false
Symlinked dotfiles: false
Only insert on tab: false
Installation Script: true
PseudoTerminal Path:
SecureKeyboardInput: false
SecureKeyboardProcess: <none>
Current window identifier: 601/% (com.googlecode.iterm2)
Fig environment variables:
  - TERM_SESSION_ID=w0t0p0:2E6FD260-7103-4810-812E-1A729D0747A9
  - FIG_INTEGRATION_VERSION=5
  - FIG_TERM=1
  - FIG_TERM_VERSION=3
  - FIG_ENV_VAR=1
  - FIG_CHECKED_PROMPTS=1
mschrage commented 2 years ago

See also #714.

clo4 commented 2 years ago

Maybe in the case that it's unable to connect, it should try again after 5 seconds, then again after another 5?

This would probably help in the case that Fig launches (or invalidates a cache?) before the network interface is up, which would be my guess for what's happening here

yurakruhlyk commented 2 years ago

@SeparateRecords Maybe there is possible to check when the device goes offline and after that when the device is online just to load all needed files again?

brendanfalk commented 2 years ago

Seems to be issue with internet connection not being established on mac load. Fig is trying to load autocomplete but because there is no internet, we can't. Fig tries to reconnect to the internet just once.

Proposed solution We should attempt to reconnect to the internet multiple times but with an exponential back off. This should be done from the autocomplete app.

We should also indicate to the user that autocomplete didn't load. The autocomplete app should notify the desktop app that there was an error with the internet and should put this in the debugger

brendanfalk commented 2 years ago

We implemented the solution discussed above except do not yet have a notification telling users that their wifi is enabled.

We still need to enable users to download the specs locally so it can work offline

brendanfalk commented 2 years ago

We will likely enable users to download specs locally by running npm install -g @fig/autocomplete

brendanfalk commented 2 years ago

This should be fixed! Please comment below if not :)