Skip to content

Incorrect background job status #25

Closed
@junkblocker

Description

@junkblocker

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

Activity

skywind3000

skywind3000 commented on Dec 19, 2016

@skywind3000
Owner

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

skywind3000 commented on Dec 19, 2016

@skywind3000
Owner

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

skywind3000

skywind3000 commented on Dec 19, 2016

@skywind3000
Owner

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

junkblocker

junkblocker commented on Dec 19, 2016

@junkblocker
Author

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

sir-pinecone commented on Oct 16, 2017

@sir-pinecone

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

sir-pinecone commented on Oct 16, 2017

@sir-pinecone

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

sir-pinecone commented on Oct 16, 2017

@sir-pinecone

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

skywind3000 commented on Oct 17, 2017

@skywind3000
Owner

don't press ctrl-c

sir-pinecone

sir-pinecone commented on Oct 17, 2017

@sir-pinecone

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

antoinemadec commented on Dec 21, 2017

@antoinemadec

@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

skywind3000 commented on Dec 21, 2017

@skywind3000
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

antoinemadec commented on Dec 21, 2017

@antoinemadec

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

antoinemadec commented on Dec 22, 2017

@antoinemadec

: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

antoinemadec commented on Jan 17, 2018

@antoinemadec

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

7 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @junkblocker@sir-pinecone@skywind3000@stewartimel@antoinemadec

        Issue actions

          Incorrect background job status · Issue #25 · skywind3000/asyncrun.vim