-
Notifications
You must be signed in to change notification settings - Fork 35
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
workers getting killed in 1.8.0+ #42
Comments
I've been able to reduce this down a lot: async_start_worker gitprompt
async_register_callback gitprompt refresh_prompt_callback
refresh_prompt_callback() {
local job=$1 err=$2
case $job in
\[async])
# Async worker has crashed
if (( err == 2 )) || (( err == 3 )) || (( err == 130 )); then
echo "ERROR($err)"
fi
;;
esac
} Running this in an interactive shell and then quickly refreshing the prompt causes the worker to be killed. Any tips on how this could be debugged further? |
Thanks for reporting. I find it strange that 361dc17 is the root cause. It's a commit that doesn't really touch on any worker logic, only modifies the startup procedure a bit. I'm guessing you tried commits before and after to determine that this is where it started? On what system and version of Zsh are you running into these issues? If I was to venture a guess, I'd think Also, are you receiving any async error messages (i.e. the ones named
This error should be avoidable by first checking that ZLE is active, |
I tried quite a few commits but I could have made some mistakes in my testing. All I can say for sure is that 1.7.2 didn't exhibit any issues and 1.8.0 does.
I'm running on rhe7 using a linuxbrew build of zsh 5.8
This was my first guess too but It didn't seem to make any difference.
Using my second code snippet the async error code is
I saw this in the pure.zsh code. Whilst it will work around the error, I'm really curious as to why I'm seeing this now and not before. For now I have been able to workaround the worker being killed by restarting it every time in Thanks |
This error originates from: Line 360 in 490167c
I'm also curious to know if you are reproducing the errors with the minimal configs you posted, exactly as-is? I.e. no other zsh plugins, settings, etc. And if so, could it be something |
I also reduced down my |
This consistently produces the error for me: async_start_worker gitprompt
async_register_callback gitprompt refresh_prompt_callback
foo() {
A="a b c d"
vared A
}
zpty testpty foo
zpty -d testpty
refresh_prompt_callback() {
local job=$1 err=$2
case $job in
\[async])
# Async worker has crashed
if (( err == 2 )) || (( err == 3 )) || (( err == 130 )); then
echo "ERROR($err): $5"
fi
;;
esac
} |
Ok, this definitely looks like an issue I've been combating since day one. Zpty destroy signals (i.e. HUP) is propagated to all Most likely this change is the root cause of your current issues: 32548d3#diff-c7f89cff42efffc19f69071441a12a1cR86-R90 It should've been fixed by this commit: zsh-users/zsh@caddeca. But alas, we may have to revert the TRAPHUP change from above. |
Is there any workarounds for this? I run into this many times a day which is a bit of a pain (but still better than not using zsh-async!) |
@howardjohn If it's any help, the only thing I was able to do was reinitializing the workers when they die. The second argument that is given to the callback function is the return code. Docs on all the return codes:
By just checking for this return code in the callback, you can reinitialize your workers when needed. I haven't had a problem in months with typewritten since I implemented that check. Example of callback function checking for the return code: tw_prompt_callback() {
local tw_name=$1 tw_code=$2 tw_output=$3
# Check for return codes indicating an error
if (( tw_code == 2 )) || (( tw_code == 3 )) || (( tw_code == 130 )); then
# reinit async workers
async_stop_worker tw_worker # stop the current worker
tw_async_init_worker # Init the worker again, and register the callback, see below
tw_async_init_tasks # Init all the tasks
elif (( tw_code )); then
# return code is not empty, reinit all tasks
tw_async_init_tasks
fi;
...
}
# For reference purpose
tw_async_init_worker() {
async_start_worker tw_worker -n
async_register_callback tw_worker tw_prompt_callback
} |
@howardjohn I'm working on some improvements, but I can't say for sure if they will help. First off, how are you using zsh-async? I've never been able to reproduce constant worker death but I know some scenarios that can cause it. For instance, sending hundreds of jobs to the worker in quick succession. Edit: And what version of zsh are you using? It'd be great if you could try out #45, then maybe #49. And finally there's a pretty huge rewrite going on in the (very WIP) @reobin it's not ideal, but indeed the best solution for current |
@reobin thanks! that is essentially what i have been doing manually, ran it for a few hours and seems great. I use it for my prompt, so it gets a decent number of jobs (every time I hit enter) but shouldn't be more than a couple per second I also haven't reproduced it consistently so its hard to quickly test out changes but I can throw them in my shell for a while and see what happens
|
@howardjohn Thanks for testing, and too bad about the workaround. If it's any help, here's how we set the worker restart up in Pure: https://github.com/sindresorhus/pure/blob/dfc8062c64df8821eaec7d741c75f3cee20d37e3/pure.zsh#L478-L495 |
As expected, I had the workaround messed up, simple type 🤦♀️ . I verified the workaround does work, added some logging when it occurs so I see its transparently happened a couple times. Unfortunately seems like #49 did not seem to help much here during my testing. |
Update: 3 months later, the workaround to reset works great. Not sure if this was known or not, but this can easily reproduce at least one occurrence of this (I have it print that it is restarting when it is triggered):
|
Trying to fix occasional: widgets can only be called when ZLE is active Following the example of: - https://github.com/sindresorhus/pure/blob/dfc8062c64df8821eaec7d741c75f3cee20d37e3/pure.zsh#L478-L495 Found via: - mafredri/zsh-async#42 If this doesn't work, see also: - ohmyzsh/ohmyzsh#3620
I've recently updated from 1.7.2 and I have found that 361dc17 has caused a regression in my setup.
I use zsh-async to update my prompt with git info. Here's my implementation with only the relevant parts:
When I quickly refresh my prompt (pressing enter quickly in sucession), it causes my
gitprompt
worker to be killed. I also get a zle error.I got neither of these problems on 1.7.2. I guess the problem is something to do with using the zle watcher?
Any help on this would be greatly appreciated.
The text was updated successfully, but these errors were encountered: