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

Incorrect background job status #25

Closed
junkblocker opened this issue Dec 19, 2016 · 20 comments
Closed

Incorrect background job status #25

junkblocker opened this issue Dec 19, 2016 · 20 comments

Comments

@junkblocker
Copy link

Sometimes AsyncRun gets stuck thinking the background job is still running and won't allow further runs of the job.

ERROR: background job is still running

Verified that the process ran isn't running. AsyncStop doesn't seem to help.

MacVim 8.0.134

@skywind3000
Copy link
Owner

skywind3000 commented Dec 19, 2016

I will inspect it. Do you have any clue to reproduce it ? Could you see the "[Finished in xxx seconds]" in the quickfix window when vim got stuck ?

@skywind3000
Copy link
Owner

Does ":AsyncStop!" help (AsyncStop with a "!" ) ?

@skywind3000
Copy link
Owner

The latest MacVim includes only 8.0.124.
How can you use 8.0.134 ??

@junkblocker
Copy link
Author

junkblocker commented Dec 19, 2016

I am not doing anything special. I have a command run on every document save. After a while the problem appears. It is possible that at some point MacVim stopped responding to input and I had to Ctrl+C a few times it which got it unstuck but that maybe prevents some state cleanup. No I don't see the message in quickfix window.

I built MacVim myself applying patches from upstream also (all scripted away). So usually have newer versions that officially available MacVim build. BTW, if you build directly from head, it is at 134 already as of a few days ago ( https://github.com/macvim-dev/macvim/commits/master ) without any manual patching needed.

I'll try AsyncStop! next time the problem appears.

@sir-pinecone
Copy link

I have this same problem and it's starting to make me a little crazy. I use this plugin to run a build script so that I can quickly compile the code I'm editing. I just updated the plugin today and the frequency of the jobs getting stuck has gone up.

I tried AsyncStop! and it doesn't help, nor does AsyncStop.

My build command is: nnoremap <leader>b :AsyncRun! -save=2 ./build*<cr> with build* being some shell script that kicks off a MSVC process. I see the [Finished in X seconds] message and a success status. I don't know how to consistently recreate the bug though. It just seems to randomly happen and I have to close vim to get it working again.

I'm using vim 8.0 with patches 1-606 on Windows 7. I built it myself.

@sir-pinecone
Copy link

sir-pinecone commented Oct 16, 2017

I also have another command that sometimes triggers this bug:

function! HideAsyncResults()
  call asyncrun#quickfix_toggle(g:build_window_size, 0)
endfunction

function! SilentBuild()
  AsyncStop
  exec "AsyncRun! -save=2 -post=call\\ HideAsyncResults() ./build*"
endfunction

nnoremap <F8> :call SilentBuild()<cr>

I wonder if the -save=2 flag is the culprit. I'm going to remove it for a bit and see if that helps.
UPDATE: still experiencing this when I remove -save=2

@sir-pinecone
Copy link

I noticed that if I get into the stuck state and then try to reload my vimrc using so $MYVIMRC I get this error: Error detected while processing function AsyncRun_Job_OnTimer[11]..<SNR>51_AsyncRun_Job_Update:

Followed by these two errors repeatedly until I close vim

E716: Key not present in Dictionary: raw == 1
E15: Invalid expression: s:async_info.raw == 1

@skywind3000
Copy link
Owner

don't press ctrl-c

@sir-pinecone
Copy link

don't press ctrl-c

Can you please be more specific? I don't recall pressing ctrl-c at any point when experiencing the stuck job state I described above.

@antoinemadec
Copy link

antoinemadec commented Dec 21, 2017

@skywind3000 I have the same issue on Ubuntu16.04, vim 8.0.14.18 (complied today).
The issue happens only if the command is executed super fast.

For instance, the following command works fine and can be repeated as many time as I want:
:AsyncRun sleep 1; echo foo

However, the second execution of the follwing command will trigger the error "ERROR: background job is still running":
:AsyncRun echo foo
The first execution does not print [Finished in ? seconds].
Also, AsyncStop! does not help.

Do you know what that could be ?
Thanks for the excellent plugin anyway :)

Antoine

@skywind3000
Copy link
Owner

sorry, it can't be reproduced on my debian / cygwin and mac os x.
Could you try to disable other plugins temporarily before invoking AsyncRun ?

@antoinemadec
Copy link

Thanks for the quick response.
I did some investigation, here is the minimal vimrc to reproduce the bug:

call plug#begin('~/.vim/plugins_by_vimplug')
Plug 'skywind3000/asyncrun.vim'
call plug#end()
set nocompatible

autocmd BufWinEnter * call system("sleep 1")

Also, you have to add copen | to trigger the issue:
:copen | AsyncRun echo foo

Running that command will trigger autocmd system("sleep 1"), echo foo finishes first, hence the bug.

I hope this help,
Antoine

@antoinemadec
Copy link

:help job says:
Note that if the job exits before you read the output, the output may be lost.
This depends on the system (on Unix this happens because closing the write end
of a pipe causes the read end to get EOF). To avoid this make the job sleep
for a short while before it exits.

@antoinemadec
Copy link

@skywind3000 , do you have any news about this bug ?
Were you able to reproduce it ?

@skywind3000
Copy link
Owner

skywind3000 commented Feb 8, 2018

I have changed the order of some variable assigment for better state handling. Please update.

@skywind3000
Copy link
Owner

skywind3000 commented Feb 8, 2018

This issue seems to be fixed by #92 and should be closed now. If you still encounter this error, you can reopen it.

@antoinemadec
Copy link

Your latest commit has been tested and works as well.
Thanks a lot !

@sir-pinecone
Copy link

Thanks so much @antoinemadec, you rock! And thanks @skywind3000 for the awesome plugin.

@woshichuanqilz
Copy link

woshichuanqilz commented Oct 27, 2020

I still have this issue, just install the Asyncrun today.
It happens when I edit the vimrc(init.vim) file then I run command
AsyncRun alacritty, alacritty started, then come back to the previous nvim window, then press :w to save the file.
Error shows:

Error detected while processing function AsyncRun_Job_OnTimer[11].57_AsyncRun_Job_Update:
line 12:
E716 Key not prsent in Dictionary: errorformat

Seems Just happened when edit vimrc file how to solve this?

nvim v0.4.4
Manjaro 20.1.2 Mikah

@stewartimel
Copy link

Same here. My issue happens if I reload my init.vim file while in vim:
:source init.vim
When I run a :w, it shows the "Error: background job is still running".

This is my AsyncRun command in my init.vim:
au BufWritePost * :AsyncRun sh generate_tags.sh

Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants