lsp-grammarly icon indicating copy to clipboard operation
lsp-grammarly copied to clipboard

Server Restart loop with error.

Open bevsxyz opened this issue 3 years ago • 2 comments

Hi,

I updated my config recently after deleting my emacs dir. Now Grammarly stopped working. The issue is that the server tries to start but encounters an error and asks to restart. This behavior goes on loop if I answer yes. The stderr buffer shows the following error,

TypeError: Cannot read properties of undefined (reading 'get')
    at h (/home/bevan/.config/emacs/.local/etc/lsp/npm/@emacs-grammarly/grammarly-languageserver/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/@grammarly/sdk/lib/index.node.js:17:597)
    at Module.<anonymous> (/home/bevan/.config/emacs/.local/etc/lsp/npm/@emacs-grammarly/grammarly-languageserver/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/@grammarly/sdk/lib/index.node.js:17:677)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/bevan/.config/emacs/.local/etc/lsp/npm/@emacs-grammarly/grammarly-languageserver/lib/node_modules/@emacs-grammarly/grammarly-languageserver/dist/index.node.cjs:10:13)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)

Process grammarly-ls stderr<1> finished

bevsxyz avatar Aug 15 '22 16:08 bevsxyz

Are you using the newer language server? Try upgrade your Node.JS to 16 LTS and reinstall the language server. If these don't work, try start the language server manually through the command line:

/home/bevan/.config/emacs/.local/etc/lsp/npm/@emacs-grammarly/grammarly-languageserver/grammarly-languageserver --stdio

It should print out the error if something went wrong!

jcs090218 avatar Aug 15 '22 16:08 jcs090218

I also encounter this exact issue. Here are the steps I tried using node.js v16.17.0:

nvm install --lts

Output

Installing latest LTS version.
v16.17.0 is already installed.
Now using node v16.17.0 (npm v8.15.0)
npm install -g @emacs-grammarly/grammarly-languageserver
rehash
grammarly-languageserver --stdio

Output (shortened):

grammarly-languageserver --stdio
/home/meggiman/.nvm/versions/node/v16.17.0/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/@grammarly/sdk/lib/index.node.js:17
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("node:perf_hooks")...<rest of minified code ommited>

                                                                                                                                                                                                                                            ^

TypeError: Cannot read properties of undefined (reading 'get')
    at h (/home/meggiman/.nvm/versions/node/v16.17.0/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/@grammarly/sdk/lib/index.node.js:17:597)
    at Module.<anonymous> (/home/meggiman/.nvm/versions/node/v16.17.0/lib/node_modules/@emacs-grammarly/grammarly-languageserver/node_modules/@grammarly/sdk/lib/index.node.js:17:677)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/meggiman/.nvm/versions/node/v16.17.0/lib/node_modules/@emacs-grammarly/grammarly-languageserver/dist/index.node.cjs:10:13)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)

I also tried various other versions of nodejs with the same effect. Do I have to install the package differently? If so, how do I tell emacs to use a different version of the package? For now I just replicated the steps manually that emacs performs when it auto installs grammarly-ls (i.e. installing from npm registry)...

meggiman avatar Aug 16 '22 20:08 meggiman

Sorry, I made the judgement too quick. It seems like an upstream issue from @grammarly/sdk package due to their recent updates?

@znck Sorry to ping you here. 😓 But I think you might want to checkout this issue. 😅

Edit: For the previous working version of sdk is 1.8.1, not working version is 1.10.0.

jcs090218 avatar Aug 17 '22 05:08 jcs090218

Will release a patch tomorrow.

znck avatar Aug 18 '22 00:08 znck

@znck & @jcs090218 Thanks a lot. For me, it is working once again with version 1.10.1 of @grammarly/sdk

meggiman avatar Aug 25 '22 07:08 meggiman

It works now after reinstalling the server. Thank you!

bevsxyz avatar Aug 29 '22 10:08 bevsxyz