Skip to content
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

Async section are not rendering #1193

Open
2 tasks done
jamerst opened this issue Sep 8, 2022 · 51 comments
Open
2 tasks done

Async section are not rendering #1193

jamerst opened this issue Sep 8, 2022 · 51 comments
Labels
async Everything related to async rendering bug Bug related to code base, behavior, displaying, etc. help-wanted We need help to resolve this issue or PR.

Comments

@jamerst
Copy link

jamerst commented Sep 8, 2022

Is there an existing issue for this?

  • Yes, I have searched the existing issues
  • Yes, I have checked troubleshooting page

The problem

The rendering of async sections such as Git is not reliable and frequently fails to render:
image

It seems to be random with no discernible pattern. The async indicator (...) also never disappears, it is always there, and the async count is always 23 when enabled.

Relevant Zsh configuration

(Loaded with Antibody)
source $dotfilesZsh/zsh_plugins.sh
SPACESHIP_PROMPT_ADD_NEWLINE="false" # disable newline before prompt

Contents of zsh_plugins.sh:
source /home/james/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-spaceship-prompt-SLASH-spaceship-prompt/async.zsh
source /home/james/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-spaceship-prompt-SLASH-spaceship-prompt/spaceship.zsh
fpath+=( /home/james/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-spaceship-prompt-SLASH-spaceship-pro

What is version of Spaceship are you using?

v4.2.5

What is version of Zsh are you using?

5.8.1

What operation system are you running?

Fedora Linux 36 (Cinnamon)

Do you use any Zsh framework or plugin manager?

Antibody

Which terminal emulator do you use?

Gnome Terminal (v3.44.1)

Additional information

No response

@jamerst jamerst added the bug Bug related to code base, behavior, displaying, etc. label Sep 8, 2022
@denysdovhan
Copy link
Member

Interesting. I guess maybe async worker fails sometimes. Maybe we can fix that be restarting it.

If you're struggling with the async rendering, you can try disabling it for now, by:

SPACESHIP_PROMPT_ASYNC=false

@denysdovhan denysdovhan added the help-wanted We need help to resolve this issue or PR. label Sep 9, 2022
@anoduck
Copy link

anoduck commented Sep 10, 2022

Not sure if this is related, but it sounds like they might be akin to one another. I just updated via antigen, and received something like async worker not found: spaceship.

Disabling async via the above command, stopped the error. It was extremely annoying there for a moment.

@haschu
Copy link

haschu commented Sep 13, 2022

Same issue as @anoduck here.

@laduchesneau
Copy link

I also have the issue as @jamerst. I have the same setup, Fedora Workstation, Gnome Termnial, ZSH version.

I have disabled async untill the main issue is found.

@Seltyk
Copy link

Seltyk commented Sep 15, 2022

This issue can cause printing of the prompt (or part of it) twice. In my case, having git in the SPACESHIP_PROMPT_ORDER list will print part of my prompt, a line separator, then the entire prompt. There is a brief moment, less than a 10th of a second perhaps, where an async warning is displayed. I do not have to be in a git repository to experience this bug. Adding SPACESHIP_PROMPT_ASYNC=false fixes the issue.

@zachliu
Copy link
Contributor

zachliu commented Sep 17, 2022

i can provide another data point here:

i did have the same issue as @jamerst under zsh-5.8 but when I upgraded to zsh-5.9, it actually became less random unless you hit enter fast

2022-09-16_23-23

Linux mint 20.3 una
alacritty 0.10.1
tmux 3.3a

@anoduck
Copy link

anoduck commented Sep 19, 2022

@haschu Beginning to believe that receiving the message async_worker_eval: no such async worker: spaceship is completely separate from this issue. Going to open a new issue, and reference here.

@denysdovhan
Copy link
Member

I guess that's because Spaceship doesn't handle worker failure properly. We have a todo-task for it here:

https://github.com/spaceship-prompt/spaceship-prompt/blob/master/lib/core.zsh#L61-L67

We should implement worker error handling, something like pure prompt has:

https://github.com/sindresorhus/pure/blob/main/pure.zsh#L507-L530

@denysdovhan
Copy link
Member

Hey, everyone! I've tried to resolve the issue. Now the worker is trying to relaunch itself when it gets failed. Hopefully this will help to resolve the issue. Let me know if it doesn't.

@zachliu
Copy link
Contributor

zachliu commented Sep 23, 2022

i'm using the latest 192231e but the async doesn't work at all. SPACESHIP_PROMPT_ASYNC=false has to be there otherwise no async sections can be seen 😢

@rwendell
Copy link

I am also having the same issue as above, adding SPACESHIP_PROMPT_ASYNC=false fixes for me, but it is noticeably slower

when adding SPACESHIP_ASYNC_SHOW_COUNT=true this is the output of my prompt:

~ …25
➜ spaceship print

%{%B%F{cyan}%}%(4~||)%3~%{%b%f%}%{%B%} %{%b%}%{%B%F{gray}%}…25%{%b%f%}%{%B%F{white}%}
%{%b%f%}%{%B%F{green}%}➜ %{%b%f%}%     

running WSL2
zsh 5.8
spaceship 4.5

@zachliu
Copy link
Contributor

zachliu commented Sep 29, 2022

I need to revise my comments: it's not "the async doesn't work at all". a more precise description would be:

  1. initial success rate is low, need to hit a few more "enters":
    2022-09-29_11-18
  2. certain section has a much higher failure rate, eg, terraform:
    2022-09-29_11-19

also i tried to:

  1. edit the terraform section to mimic the python section
  2. move terraform section higher in the SPACESHIP_PROMPT_ORDER

sadly the failure rate remains unchanged

@denysdovhan
Copy link
Member

Hopefully this PR #1246 will help to partly resolve this problem.

@zachliu
Copy link
Contributor

zachliu commented Sep 29, 2022

Hopefully this PR #1246 will help to partly resolve this problem.

isn't #1246 only about the kubectl section? 🤔

@denysdovhan
Copy link
Member

@zachliu yes, but it could block the whole process blocking the rendering of other sections

@zachliu
Copy link
Contributor

zachliu commented Sep 29, 2022

i see, i'm not using the kubectl section. but i'm going to dig a bit deeper on the terraform section. its behavior is particularly troubling

@ibhagwan
Copy link
Contributor

I have this issue on most sections, even on git (both branch and status), just ended up ditching async altogether.

@zachliu
Copy link
Contributor

zachliu commented Sep 29, 2022

ok new data point:

before my terraform section, i have

user
host
dir
git
venv
python
terraform

in order for the terraform section to work properly (close to 95% success rate) under async paradigm, i have to comment out these three culprits:

dir
venv
python

now here comes the fun part:

  1. keeping dir, 29% success rate on terraform
  2. keeping venv, 29% success rate on terraform even if i comment out everything in spaceship_venv()
  3. keeping python, 87% success rate on terraform

@denysdovhan
Copy link
Member

denysdovhan commented Oct 5, 2022

Okay, I've finally run into the similar problem. I got async section stuck always displaying . For me, it was resolved by removing dotnet section.

UPD: Though, removing only dotnet section doesn't help. Seems like the problem is with something else, still digging.

@anoduck
Copy link

anoduck commented Oct 6, 2022

@denysdovhan I really feel for ya.

@denysdovhan
Copy link
Member

Hey everyone, check v4.6.0 version. It resolved the issue with always displaying ... for me. Let me know if that helps.

@zachliu
Copy link
Contributor

zachliu commented Oct 7, 2022

it's still the same for me: dir, venv and python are "blocking" the terrraform section 😢

Linux mint 20.3 una
alacritty 0.10.1
tmux 3.3a
zsh 5.9 (x86_64-pc-linux-gnu)

@aidistan
Copy link

aidistan commented Oct 12, 2022

The same issue still exists in v4.6.0 for me. Several sections are always blocked by dir, while others don't. Guess it is related to the running speed.

My workaround is to disable async for those slow sections, such as:

SPACESHIP_RUBY_ASYNC=false

@laduchesneau
Copy link

Issue still persist for me

@mufasa71
Copy link

mufasa71 commented Jan 8, 2023

Ok, got it working with latest zsh-async

MacOS Ventura zsh 5.8.1 spaceship 4.13.1

Screenshot 2023-01-08 at 12 37 08

@KyleOndy
Copy link

KyleOndy commented Jan 8, 2023

I can test the latest (v1.8.6) version of zsh-async later today and see it if works for me. If so, I'll push that update into nixpkgs too.

@KyleOndy
Copy link

KyleOndy commented Jan 8, 2023

Inital testing doesn't show any change for me. I'll check everything is wired together since @mufasa71 seems to be working with the latest zsh-async.


👇 More for my information when I come back to this
PR into this repo: #1316
nixpkg with above pr: KyleOndy/nixpkgs@c41ea62
using the new spaceship package locally: KyleOndy/dotfiles@main...spaceship_async

@mufasa71
Copy link

mufasa71 commented Jan 8, 2023

@KyleOndy if you have old async.zsh.zwc cache file, it needs to be removed, otherwise it may not work.

@KyleOndy
Copy link

KyleOndy commented Jan 9, 2023

@mufasa71 , hmm, I'll need to look into that. In a fresh environemnt I do see the git branch information with SPACESHIP_PROMPT_ASYNC=true and v1.8.6 of async.zsh.

So its likely there is some cache on my local setup, I need to do some digging into where these caches are.

@denysdovhan
Copy link
Member

denysdovhan commented Jan 11, 2023

I pushed the updated zsh-async v1.8.6 to master branch. No published version yet. Please let me know if this resolves this issue for you (especially those who use Linux distros).

Use the latest master (should be loaded automatically if you use any zsh plugin manager tool, like zgen, zplug, etc)

@pipoprods
Copy link

I'm still having issues (Debian 11 / Zsh 5.8 / f174447)

image

@dmint789
Copy link

When should we expect async loading to be fixed?

@denysdovhan
Copy link
Member

denysdovhan commented Feb 16, 2023

@dmint789 unfortunately I can't give exact ETA for the fix of this problem. I understand that you really want this to be fixed, but try to understand that I'm maintaining this project in my free time, besides my daytime job, missile strikes and electricity outages during the war.

Any help with this issue is highly appreciated. Thanks for understanding!

@anoduck
Copy link

anoduck commented Feb 16, 2023

@dmint789 unfortunately I can't give exact ETA for the fix of this problem. I understand that you really want that to be fixed, but try to understand that I'm maintaining this project in my free time, besides my daytime job, missile strikes and electricity outages due to war.

Any help with this issue is highly appreciated. Thanks for understanding!

Dude, seriously... be careful out there. We completely understand.

@webknjaz
Copy link
Contributor

FTR Fedora still has this problem. I was showing the theme to a newbie on a clean F38 install with omz and all we ever saw was ...

@Soneji
Copy link
Contributor

Soneji commented May 24, 2023

I had the same problem, solution was turning off all the plugins I dont actually use 😅

@anoduck
Copy link

anoduck commented May 25, 2023

Enabled sections:

SPACESHIP_PROMPT_ORDER=(                                                                                                                                                                                                                                                   
  # user          # Username section                                                                                                                                                                                                                                       
  dir           # Current directory section                                                                                                                                                                                                                                
  host          # Hostname section                                                                                                                                                                                                                                         
  git           # Git section (git_branch + git_status)                                                                                                                                                                                                                                                                                                                                                                                                                                                            
  python        # Python section                                                                                                                                                                                                                                                                                                                                                                                                                                                               
  # venv          # virtualenv section                                                                                                                                                                                                                                     
  # conda         # conda virtualenv section                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  exec_time     # Execution time                                                                                                                                                                                                                                           
  async         # Async jobs indicator                                                                                                                                                                                                                                     
  # line_sep      # Line break                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  jobs          # Background jobs indicator                                                                                                                                                                                                                                
  exit_code     # Exit code section                                                                                                                                                                                                                                        
  # time          # Time stampts section                                                                                                                                                                                                                                   
  char          # Prompt character                                                                                                                                                                                                                                         
  )

The setup is pretty lean.

@dmint789
Copy link

@denysdovhan Yes, I totally understand. It's not such a big deal, since there is the option to disable async rendering.

@dmint789
Copy link

@anoduck That didn't work for me unfortunately, still shows ... for the async section

@anoduck
Copy link

anoduck commented Jul 20, 2023

@anoduck That didn't work for me unfortunately, still shows ... for the async section

@dmint789 Just some basic, and probably stupid questions.

  1. What happens when you comment out everything? Does it still show?
  2. A really dumb one: Have you looked to see if there is another configuration stuck somewhere?
  3. Have you tested async by itself to see if it runs on your system? denysdovhan provided the test script further up in this thread.
  4. Have you tried it standing on one leg, with finger touching the tip of your nose, while hopping up and down? Because if you haven't, then you would be missing out on a lot of fun.
  5. I hate suggesting this one, but have you tried the rust alternative startship?

@rpadovani
Copy link

Hey all,
I spent some hours on this today because I find it quite annoying.

I think I was able to pinpoint the issue to zpty: it seems that if the command is too quick, it doesn't properly return it.

This also explains because in this issue we have seen many different prompts having the issue: at the end of the day, it is up to how long a command takes, and there are so many variables...

On my PC, I noticed that the threshold is around 50ms: if any command takes less than that, then it is not properly returned by zpty.

As a temporary workaround, I set a sleep 0.05 in the _async_job() function.

diff --git a/async.zsh b/async.zsh
index de13e75..8a8a981 100644
--- a/async.zsh
+++ b/async.zsh
@@ -28,6 +28,8 @@ _async_job() {
        # Disable xtrace as it would mangle the output.
        setopt localoptions noxtrace
 
+       sleep 0.05
+
        # Store start time for job.
        float -F duration=$EPOCHREALTIME

This addresses the problem for me, although now the prompt is way slower (0.05s of delay for each section).

I wonder if the root cause is a bug in zpty, or the problem is that spaceship is using one worker for everything, and results are so quick that begin arriving before all the inputs have been inserted, mangling the results...
Probably, something to try would be using a different worker for each section.

Hope it can be useful!

@denysdovhan
Copy link
Member

@rpadovani Hey, this is a great finding. I've been dinging deep into this problem as well. I also found that adding a sleep 0.1 fixes the issue for me, but it seemed like a stupid solution.

I believe we should work together in order to fix that problem at zsh-async side. Could you create an issue and share your findings? Please, mention this issue there.

@FaisalBudiono
Copy link

FaisalBudiono commented Sep 29, 2023

Hey all, I spent some hours on this today because I find it quite annoying.

I think I was able to pinpoint the issue to zpty: it seems that if the command is too quick, it doesn't properly return it.

This also explains because in this issue we have seen many different prompts having the issue: at the end of the day, it is up to how long a command takes, and there are so many variables...

On my PC, I noticed that the threshold is around 50ms: if any command takes less than that, then it is not properly returned by zpty.

As a temporary workaround, I set a sleep 0.05 in the _async_job() function.

diff --git a/async.zsh b/async.zsh
index de13e75..8a8a981 100644
--- a/async.zsh
+++ b/async.zsh
@@ -28,6 +28,8 @@ _async_job() {
        # Disable xtrace as it would mangle the output.
        setopt localoptions noxtrace
 
+       sleep 0.05
+
        # Store start time for job.
        float -F duration=$EPOCHREALTIME

This addresses the problem for me, although now the prompt is way slower (0.05s of delay for each section).

I wonder if the root cause is a bug in zpty, or the problem is that spaceship is using one worker for everything, and results are so quick that begin arriving before all the inputs have been inserted, mangling the results... Probably, something to try would be using a different worker for each section.

Hope it can be useful!

This work really great! It solve the issue in my device. I use sleep 0.5, I think it's because my device is slower than yours but anyway it works like a charm! Thanks a lot!

@ZeyadMoustafaKamal
Copy link

I found a solution for this, I hope it works for you also

in .zshrc add this which you can find in the docs here

SPACESHIP_PROMPT_ORDER=(
  time           # Time stamps section
  user           # Username section
  dir            # Current directory section
  host           # Hostname section
  git            # Git section (git_branch + git_status)
  hg             # Mercurial section (hg_branch  + hg_status)
  package        # Package version
  node           # Node.js section
  bun            # Bun section
  deno           # Deno section
  ruby           # Ruby section
  python         # Python section
  elm            # Elm section
  elixir         # Elixir section
  xcode          # Xcode section
  swift          # Swift section
  golang         # Go section
  perl           # Perl section
  php            # PHP section
  rust           # Rust section
  haskell        # Haskell Stack section
  scala          # Scala section
  kotlin         # Kotlin section
  java           # Java section
  lua            # Lua section
  dart           # Dart section
  julia          # Julia section
  crystal        # Crystal section
  docker         # Docker section
  docker_compose # Docker section
  aws            # Amazon Web Services section
  gcloud         # Google Cloud Platform section
  azure          # Azure section
  venv           # virtualenv section
  conda          # conda virtualenv section
  dotnet         # .NET section
  ocaml          # OCaml section
  vlang          # V section
  zig            # Zig section
  purescript     # PureScript section
  erlang         # Erlang section
  kubectl        # Kubectl context section
  ansible        # Ansible section
  terraform      # Terraform workspace section
  pulumi         # Pulumi stack section
  ibmcloud       # IBM Cloud section
  nix_shell      # Nix shell
  gnu_screen     # GNU Screen section
  exec_time      # Execution time
  async          # Async jobs indicator
  line_sep       # Line break
  battery        # Battery level and status
  jobs           # Background jobs indicator
  exit_code      # Exit code section
  sudo           # Sudo indicator
  char           # Prompt character
)

and then delete everything you don't need. for me it became like this

SPACESHIP_PROMPT_ORDER=(
  time           # Time stamps section
  user           # Username section
  dir            # Current directory section
  host           # Hostname section
  git            # Git section (git_branch + git_status)
  package        # Package version
  node           # Node.js section
  bun            # Bun section
  python         # Python section
  rust           # Rust section
  docker         # Docker section
  docker_compose # Docker section
  venv           # virtualenv section
  exit_code      # Exit code section
  sudo           # Sudo indicator
)

And also don't forget to remove all plugins in plugins variable in .zshrc that you don't need for me I made it like this plugins=(git zsh-autosuggestions zsh-syntax-highlighting) and don't forget also to source ~/.zshrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async Everything related to async rendering bug Bug related to code base, behavior, displaying, etc. help-wanted We need help to resolve this issue or PR.
Development

No branches or pull requests