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

[BUG] Job: cannot resume dead coroutine with maximum-results #327

Open
cseickel opened this issue Mar 3, 2022 · 0 comments
Open

[BUG] Job: cannot resume dead coroutine with maximum-results #327

cseickel opened this issue Mar 3, 2022 · 0 comments

Comments

@cseickel
Copy link

cseickel commented Mar 3, 2022

I found a bug with the Job class: if you set maximum_results and the process encounters an error during execution, you will get this error message:

Error executing luv callback:
cannot resume dead coroutine
stack traceback:
        [builtin#36]: at 0x57ac5f2f4ad0
        [C]: in function 'wait'
        .../site/pack/packer/start/plenary.nvim/lua/plenary/job.lua:218: in function 'shutdown'
        .../site/pack/packer/start/plenary.nvim/lua/plenary/job.lua:343: in function <.../site/pack/packer/start/plenary.nvim/lua/plenary/job.lua:342>

You can recreate it reliably with this example:

local Job = require("plenary.job")

Job:new({
  command = "find",
  args = {"/", "-iname", "e"},
  maximum_results = 10,
  on_start = function ()
    print("start")
  end,
  on_stdout = function(_, data, _)
    print(data)
  end,
  on_stderr = function(_, data, _)
    print(data)
  end,
  on_exit = function(_, code, _)
    print("exit", code)
  end,
}):start()

I am trying to fix it but it's proving more difficult than I anticipated. As far as I can see, the error is caused by vim.wait returning after everything has already been cleaned up. It will work fine for a normally executing process with a clean exit, but not in this situation where a process has errors. At least this applies to using the find command when it searches directories that you don't have permissions to.

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

1 participant