Repository: neovim
Issue: provider/node.vim hang on exit
Labels: bug,performance,provider,remote-plugin

- `nvim --version`: v0.3.2-530-gdadcfe22c
- Vim (version: ) behaves differently? N/A
- Operating system/version: Debian Linux/WSL
- Terminal name/version: conhost, N/A
- `$TERM`: xterm-256color N/A

### Steps to reproduce using `nvim -u NORC`

*This isn't reproducible without any plugins.*

```
yarn global add neovim
# install remote plugin requiring node support, e.g. nvim-typescript
nvim
:UpdateRemotePlugins
:qa
```

### Actual behaviour
Neovim hangs briefly on exit. Using `set verbose=9` reveals a runtime error:

```
Searching for "/home/mqudsi/.config/nvim/autoload/provider/node.vim"
Searching for "/etc/xdg/nvim/autoload/provider/node.vim"
Searching for "/home/mqudsi/.local/share/nvim/site/autoload/provider/node.vim"
Searching for "/usr/local/share/nvim/site/autoload/provider/node.vim"
Searching for "/usr/share/nvim/site/autoload/provider/node.vim"
Searching for "/home/mqudsi/.config/nvim/bundle/repos/github.com/autozimu/LanguageClient-neovim/autoload/provider/node.vim"
Searching for "/home/mqudsi/.config/nvim/bundle/repos/github.com/mhartington/nvim-typescript/autoload/provider/node.vim"
Searching for "/home/mqudsi/.config/nvim/bundle/.cache/init.vim/.dein/autoload/provider/node.vim"
Searching for "/usr/local/share/nvim/runtime/autoload/provider/node.vim"
chdir(/mnt/c/Users/mqudsi/git/prettysize-rs)
chdir(/usr/local/share/nvim/runtime/autoload/provider)
chdir(/mnt/c/Users/mqudsi/git/prettysize-rs)
line 10: sourcing "/usr/local/share/nvim/runtime/autoload/provider/node.vim"
Error detected while processing function provider#node#Detect[4]..<SNR>70_is_minimum_version:
line    2:
E730: using List as a String
Calling shell to execute: ""

finished sourcing /usr/local/share/nvim/runtime/autoload/provider/node.vim
continuing in function remote#define#CommandBootstrap[1]..remote#host#Require
Executing FuncUndefined Auto commands for "*"
autocommand call dein#autoload#_on_func(expand('<afile>'))
Searching for "autoload/provider.vim" in "/home/mqudsi/.config/nvim,/etc/xdg/nvim,/home/mqudsi/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/home/mqudsi/.config/nv
im/bundle/repos/github.com/autozimu/LanguageClient-neovim,/home/mqudsi/.config/nvim/bundle/repos/github.com/mhartington/nvim-typescript,/home/mqudsi/.config/nvim/bundle/.cache/init.vim/.dei
n,/usr/local/share/nvim/runtime,/home/mqudsi/.config/nvim/bundle/repos/github.com/mhartington/nvim-typescript/after,/home/mqudsi/.config/nvim/bundle/.cache/init.vim/.dein/after,/usr/share/n
vim/site/after,/usr/local/share/nvim/site/after,/home/mqudsi/.local/share/nvim/site/after,/etc/xdg/nvim/after,/home/mqudsi/.config/nvim/after,/home/mqudsi/.config/nvim/bundle/repos/github.c
om/Shougo/dein.vim"
Searching for "/home/mqudsi/.config/nvim/autoload/provider.vim"
Searching for "/etc/xdg/nvim/autoload/provider.vim"
Searching for "/home/mqudsi/.local/share/nvim/site/autoload/provider.vim"
Searching for "/usr/local/share/nvim/site/autoload/provider.vim"
Searching for "/usr/share/nvim/site/autoload/provider.vim"
Searching for "/home/mqudsi/.config/nvim/bundle/repos/github.com/autozimu/LanguageClient-neovim/autoload/provider.vim"
Searching for "/home/mqudsi/.config/nvim/bundle/repos/github.com/mhartington/nvim-typescript/autoload/provider.vim"
Searching for "/home/mqudsi/.config/nvim/bundle/.cache/init.vim/.dein/autoload/provider.vim"
Searching for "/usr/local/share/nvim/runtime/autoload/provider.vim"
chdir(/mnt/c/Users/mqudsi/git/prettysize-rs)
chdir(/usr/local/share/nvim/runtime/autoload)
chdir(/mnt/c/Users/mqudsi/git/prettysize-rs)
line 14: sourcing "/usr/local/share/nvim/runtime/autoload/provider.vim"
finished sourcing /usr/local/share/nvim/runtime/autoload/provider.vim
continuing in function remote#define#CommandBootstrap[1]..remote#host#Require[10]..provider#node#Require
function remote#define#CommandBootstrap[1]..remote#host#Require[10]..provider#node#Require[14]..provider#Poll, line 4
Vim(if):ch 6 was closed by the client
node: bad option: -1
Error detected while processing function remote#define#CommandBootstrap[1]..remote#host#Require[10]..provider#node#Require[14]..provider#Poll:
line   14:
E605: Exception not caught: Failed to load node host. You can try to see what happened by starting nvim with $NVIM_NODE_LOG_FILE set and opening the generated log file. Also, the host stder
r is available in messages.
Error detected while processing function remote#define#CommandBootstrap[1]..remote#host#Require:
line   10:
E171: Missing :endif
Writing ShaDa file "/home/mqudsi/.local/share/nvim/shada/main.shada"
```

(note the **node: bad option: -1** redirected from stderr in the log above)

Setting `NVIM_NODE_LOG_FILE` does not create a log, presumably because nothing is logged this early on. `node --version` returns v8.11.2.

`:checkhealth` runs fine:

```
...
## Node.js provider (optional)
  - INFO: Node.js: v8.11.2
  - INFO: Neovim node.js host: /home/mqudsi/.config/yarn/global/node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.2.1
```

I'm not entirely sure this error alone is the reason for the delay on exit. Profiling reveals the following:

```
FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
    1   1.563946   0.000147  remote#define#CommandBootstrap()
    1   1.563326   0.000542  remote#host#Require()
    1   1.126305   0.000124  provider#node#Detect()
    2   1.108482   0.000548  <SNR>64_find_node_client()
    1   0.435341   0.000454  provider#node#Require()
    1   0.434333             provider#Poll()
```

### Expected behaviour
No hang on exit. No errors on exit.