neovim / node-client

Nvim Node.js client and plugin host
https://neovim.io/node-client/
MIT License
492 stars 53 forks source link

something in logger causing error about self._addDefaultMeta #156

Closed jeffwillette closed 4 years ago

jeffwillette commented 4 years ago

I am using a node plugin https://github.com/mhartington/nvim-typescript which requires the node host. when I use one of the functions there I get the following error in the node log...

{"message":"Error in plugin for command:TSGetDiagnostics: self._addDefaultMeta is not a function (file: /Users/Jeff/.config/nvim/plugged/nvim-typescript/rplugin/node/nvim_typescript, stack: TypeError: self._addDefaultMeta is not a function\n    at Object.DerivedLogger.<computed> [as warn] (/Users/Jeff/.config/yarn/global/node_modules/winston/lib/winston/create-logger.js:80:14)\n    at Object.getDiagnostics (/Users/Jeff/.config/nvim/plugged/nvim-typescript/rplugin/node/nvim_typescript/lib/index.js:1:24189)\n    at Object.fn (/Users/Jeff/.config/yarn/global/node_modules/neovim/lib/host/NvimPlugin.js:19:26)\n    at NvimPlugin.<anonymous> (/Users/Jeff/.config/yarn/global/node_modules/neovim/lib/host/NvimPlugin.js:155:41)\n    at Generator.next (<anonymous>)\n    at /Users/Jeff/.config/yarn/global/node_modules/neovim/lib/host/NvimPlugin.js:8:71\n    at new Promise (<anonymous>)\n    at __awaiter (/Users/Jeff/.config/yarn/global/node_modules/neovim/lib/host/NvimPlugin.js:4:12)\n    at NvimPlugin.handleRequest (/Users/Jeff/.config/yarn/global/node_modules/neovim/lib/host/NvimPlugin.js:133:16)\n    at Host.<anonymous> (/Users/Jeff/.config/yarn/global/node_modules/neovim/lib/host/index.js:71:27))","level":"error"}

It seems someone else has seen the error as well in #154. It looks like #139 is probably the same issue too. I looked into the library where this is coming from and there also seems to be some issues there https://github.com/winstonjs/winston/issues/1591 and https://github.com/winstonjs/winston/issues/1577. I looked through the files a little bit here but I cannot see the exact reason why this is happening in neovim's node client.

I haven't been using node for a while and I just updated everything to dust off an old project when I ran into this error. Does anyone see why this would be happening?

If I use the chrome debugger I run into the following console error, I am unsure if it is related or not...

internal/process/warning.js:33 (node:17278) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
mhartington commented 4 years ago

Looking into this more, but not seeing where the issue could be. Other than locking things down to winston 3.1.0, which could be done.

pyrho commented 4 years ago

Seeing this issue too, editing the package.json to set the winston version to 3.1.0 resolves the issue for me. I can submit a PR if you'd like.

Also I think it would be wise to include npm's package-lock.json too (I can do that too if you want).

Lastly, maybe a more lightweight library (such as https://www.npmjs.com/package/debug) could be considered in-place of winston, unless node-client is making active use of winston's advanced features. (I can try to make a PR for that too if you wish so (:).

Cheers !

mhartington commented 4 years ago

Can't say for certain (@billyvg ?) but I think winston was chosen because it can write to file. If this new package could support that, then maybe? But perhaps locking winston to 3.1.0 for now would be best.

The repo manages things with yarn, so the yarn lock file should manage this

pyrho commented 4 years ago

Alright, will submit a PR with the winston locked version and the yarn.lock file.

edit: Oh it seems the repo is using lerna, so I guess the top-level yarn.lock file is being used.

billyvg commented 4 years ago

Yeah I think winston was chosen so that we could use different transports