nvim: src/unix/stream.c:1405: uv__check_before_write: Assertion `nbufs > 0' failed

Viewed 73

Getting the question title error when calling the follow function. uv is vim.loop.

This is first time I'm trying to do something with vim.loop. Believe it may be something really simple.

local function call_proc(process, args, cwd, cb, print_stdout)
    local stderr = uv.new_pipe(false)
    local output = {}
    local handle, pid
    handle, pid = uv.spawn(
        process,
        { args = args, cwd = cwd, stdio = { nil, print_stdout and stderr, stderr }, env = env },
        function(code)
            stderr:read_stop()
            stderr:close()
            local log = uv.fs_open(logfile, "a+", 0x1A4)
            local log_pipe = uv.new_pipe(false)
            log_pipe:open(log)
            log_pipe:write(output, vim.schedule_wrap(function(err)
                if err then
                    vim.notify(string.format(" Paq: Failed to spawn %s (%s)", process, pid))
                end
                log_pipe:close()
                log:close()
                handle:close()
                cb(code == 0)
            end))
        end
    )
    if not handle then
        vim.notify(string.format(" Paq: Failed to spawn %s (%s)", process, pid))
    end
    stderr:read_start(function(err, data)
        if err then
            vim.notify(string.format(" Paq: Failed reading %s (%s) output", process, pid))
            return
        end
        if data then
            table.insert(output, data)
        end
    end)
end

Don't get any stacktrace when get the error.

Update

Found this uv__check_before_write function declaration, didn't had time to better understand it yet.

0 Answers
Related