Closed ChristianChiarulli closed 8 months ago
Just some notes:
not sure if
ALLOW_CONSOLE
has anything to do with this but whenever I set it to1
for instance but that doesn't seem to do anything either.
For reference: https://github.com/neovim/node-client/blob/c4ba03108dbf5360d17205f43f17a717de95cfa7/packages/neovim/src/utils/logger.ts#L21-L27
This is what I'm seeing now:
Log:
ERR 2023-07-27T00:03:39.147 nvim.40391.0 chan_close_with_error:626: RPC: failed to decode msgpack
Code:
module.exports = plugin => {
plugin.setOptions({ dev: false });
plugin.registerCommand('EchoMessage', async () => {
try {
console.log('EchoMessage'); // <---- this is what is causing the error
await plugin.nvim.outWrite('Dayman (ah-ah-ah) \n');
} catch (err) {
console.error(err);
}
}, { sync: false });
};
Node version: v16.18.0 Neovim version: NVIM v0.10.0-dev-722+g7668f89d5 Node Client from checkhealth:
Node.js provider (optional) ~
- Node.js: v16.18.0
- Nvim node.js host: /Users/chris/Library/Application Support/fnm/node-versions/v16.18.0/installation/lib/node_modules/neovim/bin/cli.js
- OK Latest "neovim" npm/yarn/pnpm package is installed: 4.10.1
chan_close_with_error:626: RPC: failed to decode msgpack
That sounds like something is writing to the channel, which can happen if code prints to stdout while you are using a stdio channel (as opposed to unix socket / named pipe / TCP). If console
isn't actually getting patched, I guess it would write to stdout? Can you confirm whether console
is actually getting monkeypatched?
I think I have the same problem with the latest version and on Windows
console.log
crashes neovimconsole.error
and console.info
do nothingThe readme mentions: https://github.com/neovim/node-client/blob/053a222b474c21217a0d96cc8d87c44792101d9c/README.md#L95
I'm guessing this isn't working or it's happening too late.
console.log crashes neovim
That's another hint that the console monkey-patching isn't in effect, thus it writes to the msgpack-RPC channel. https://github.com/neovim/node-client/issues/202#issuecomment-1656430295
I set
NVIM_NODE_LOG_FILE="$HOME/nvim_node_log"
and I see logging from the node client but not from any of the log statements in my plugin.Example logs I'm seeing:
I would expect to see the log statements defined in the plugin as well. To reproduce just check if the logs are working in the example bundled with this repo: https://github.com/neovim/node-client/tree/master/examples/rplugin/node/nvim-example
I'm also not sure if
ALLOW_CONSOLE
has anything to do with this but whenever I set it to1
for instance but that doesn't seem to do anything either.