roxma / nvim-yarp

Yet Another Remote Plugin Framework for Neovim
MIT License
230 stars 14 forks source link

[TODO] allow custom on_channel_started handler #18

Closed roxma closed 6 years ago

roxma commented 6 years ago

The module object should be loaded before channel started callback.

Due to greenlet concurrent behavior, if the module gets a message before it gets fully initialized, things will get really messy.

Shougo commented 6 years ago

The change have broken some people's environment.

His error is here.

[deoplete] [yarp] [deoplete] timeout establishing channel for ['python3', '-u', '/home/thinca/.local/share/vim/dein/repos/github.com/roxma/nvim-yarp/pythonx/yarp.py', '/tmp/vZjDeZZ/1', 2, 'deoplete']
[deoplete] function deoplete#enable[9]..deoplete#initialize[1]..deoplete#init#_initialize[10]..deoplete#init#_channel[20]..yarp#core#notify[1]..yarp#core#wait_channel, 行 18
'function deoplete#enable[9]..deoplete#initialize[1]..deoplete#init#_initialize[10]..deoplete#init#_channel'

The problem is fixed if https://github.com/roxma/nvim-yarp/commit/4bb9d3998bd770a68c508305c30ffefc16ac90eb commit is reverted.

roxma commented 6 years ago

@Shougo

Is there a reproducible docker image that I can use for test?

I cannot reproduce the issue on my local env.

Shougo commented 6 years ago

Sorry. I don't have the environment... It depends his environment.

ichizok commented 6 years ago

Repro steps

vimrc:

set rtp^=/path/to/nvim-yarp
set rtp^=/path/to/vim-hug-neovim-rpc
set rtp^=/path/to/deoplete.nvim

function! s:f()
endfunction
let g:F = function('s:f')

Start vim -Nu vimrc and execute

:call deoplete#enable()

Note: above error message is fixed by https://github.com/Shougo/deoplete.nvim/commit/7cc5da27caf1b753e122748e089a36207154c9a1, but in the situation deoplete doesn't work.

Cause

In deoplete initializing: https://github.com/Shougo/deoplete.nvim/blob/master/rplugin/python3/deoplete/context.py#L95

When g: has a variable of a reference of script-local function as above g:F, self._vim.eval('g:') hangs since the following exception occurs in rpc_server process:

Traceback (most recent call last):
  File "/home/who/.vim/bundle/repos/github.com/roxma/vim-hug-neovim-rpc/pythonx/neovim_rpc_server.py", line 400, in process_pending_requests
    packed = msgpack.packb(neovim_rpc_protocol.to_client(result))
  File "/home/who/.vim/bundle/repos/github.com/roxma/vim-hug-neovim-rpc/pythonx/neovim_rpc_protocol.py", line 66, in to_client
    return walk(handler, msg)
  File "/home/who/.vim/bundle/repos/github.com/roxma/vim-hug-neovim-rpc/pythonx/neovim_rpc_protocol.py", line 20, in walk
    return list(walk(fn, o) for o in obj)
  File "/home/who/.vim/bundle/repos/github.com/roxma/vim-hug-neovim-rpc/pythonx/neovim_rpc_protocol.py", line 20, in <genexpr>
    return list(walk(fn, o) for o in obj)
  File "/home/who/.vim/bundle/repos/github.com/roxma/vim-hug-neovim-rpc/pythonx/neovim_rpc_protocol.py", line 23, in walk
    obj.items())
  File "/home/who/.vim/bundle/repos/github.com/roxma/vim-hug-neovim-rpc/pythonx/neovim_rpc_protocol.py", line 22, in <genexpr>
    return dict((walk(fn, k), walk(fn, v)) for k, v in
  File "/home/who/.vim/bundle/repos/github.com/roxma/vim-hug-neovim-rpc/pythonx/neovim_rpc_protocol.py", line 24, in walk
    return fn(obj)
  File "/home/who/.vim/bundle/repos/github.com/roxma/vim-hug-neovim-rpc/pythonx/neovim_rpc_protocol.py", line 64, in handler
    return obj.name
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

The value of name of script-local function object starts with \x80\xfd\x52. This is an invalid sequence in UTF-8.