Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flymake bug with two backends (Was: Cannot get deno lsp working: missing field 'enable' error) #660

Closed
danielpza opened this issue Apr 3, 2021 · 24 comments

Comments

@danielpza
Copy link

danielpza commented Apr 3, 2021

I'm trying to configure eglot with deno lsp. I didn't find any issues related to the error message so I guess it has to do with my eglot configuration.

.dirs-locals.el:

((typescript-mode . ((eglot-server-programs . ((typescript-mode . ("deno" "lsp"))))
		     (eglot-workspace-configuration . (("enable" . t)
						       ("lint" . t)
						       ("unstable" . t))))))

(eglot-events-buffer):

[client-request] (id:1) Sat Apr  3 17:23:48 2021:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
	  (:processId 2361 :rootPath "/home/daniel/projects/learning-deno/" :rootUri "file:///home/daniel/projects/learning-deno/" :initializationOptions #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
																					())
		      :capabilities
		      (:workspace
		       (:applyEdit t :executeCommand
				   (:dynamicRegistration :json-false)
				   :workspaceEdit
				   (:documentChanges :json-false)
				   :didChangeWatchedFiles
				   (:dynamicRegistration t)
				   :symbol
				   (:dynamicRegistration :json-false)
				   :configuration t)
		       :textDocument
		       (:synchronization
			(:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
			:completion
			(:dynamicRegistration :json-false :completionItem
					      (:snippetSupport :json-false)
					      :contextSupport t)
			:hover
			(:dynamicRegistration :json-false :contentFormat
					      ["markdown" "plaintext"])
			:signatureHelp
			(:dynamicRegistration :json-false :signatureInformation
					      (:parameterInformation
					       (:labelOffsetSupport t)))
			:references
			(:dynamicRegistration :json-false)
			:definition
			(:dynamicRegistration :json-false)
			:declaration
			(:dynamicRegistration :json-false)
			:implementation
			(:dynamicRegistration :json-false)
			:typeDefinition
			(:dynamicRegistration :json-false)
			:documentSymbol
			(:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind
					      (:valueSet
					       [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))
			:documentHighlight
			(:dynamicRegistration :json-false)
			:codeAction
			(:dynamicRegistration :json-false :codeActionLiteralSupport
					      (:codeActionKind
					       (:valueSet
						["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"]))
					      :isPreferredSupport t)
			:formatting
			(:dynamicRegistration :json-false)
			:rangeFormatting
			(:dynamicRegistration :json-false)
			:rename
			(:dynamicRegistration :json-false)
			:publishDiagnostics
			(:relatedInformation :json-false))
		       :experimental #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
						   ()))))
[stderr] Starting Deno language server...
[stderr]   version: 1.8.3 (release, x86_64-unknown-linux-gnu)
[server-reply] (id:1) ERROR Sat Apr  3 17:23:48 2021:
(:jsonrpc "2.0" :error
	  (:code -32602 :message "missing field `enable`")
	  :id 1)
[internal] Sat Apr  3 17:23:48 2021:
(:message "Connection state changed" :change "killed\n")

----------b---y---e---b---y---e----------
[stderr] 
[stderr] 
[stderr] nil
[stderr] nil
[stderr] Process EGLOT (learning-deno/typescript-mode) stderr finished
$ emacs --version
GNU Emacs 28.0.50
Copyright (C) 2021 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
$ deno --version
deno 1.8.3 (release, x86_64-unknown-linux-gnu)
v8 9.0.257.3
typescript 4.2.2
@danielpza danielpza changed the title Cannot get deno lsp working missing field enable Cannot get deno lsp working: missing field 'enable' error Apr 3, 2021
@danielpza danielpza changed the title Cannot get deno lsp working: missing field 'enable' error Cannot get deno lsp working: missing field 'enable' error Apr 3, 2021
@danielpza danielpza changed the title Cannot get deno lsp working: missing field 'enable' error Cannot get deno lsp working: missing field 'enable' error Apr 3, 2021
@muffinmad
Copy link
Collaborator

Take a look at denoland/deno#9988

Judging from deno the manual you need to pass the enabled option as the initialization parameter and not as the workspace configuration parameter.

See https://github.com/joaotavora/eglot/blob/master/README.md#handling-quirky-servers

@danielpza
Copy link
Author

Got it to somehow work by following your suggestion:

  (add-to-list 'eglot-server-programs '((js-mode typescript-mode) . (eglot-deno "deno" "lsp")))

  (defclass eglot-deno (eglot-lsp-server) ()
    :documentation "A custom class for deno lsp.")

  (cl-defmethod eglot-initialization-options ((server eglot-deno))
    "Passes through required deno initialization options"
    (list :enable t
	  :lint t))

However got an error:

[eglot] Connected! Server `deno-language-server' now managing `typescript-mode' buffers in project `learning-deno'.
error in process sentinel: apply: Wrong type argument: flymake--backend-state, nil
error in process sentinel: Wrong type argument: flymake--backend-state, nil

@joaotavora
Copy link
Owner

However got an error:

Are you using the very latest Eglot? Can I get a backtrace? Thanks

@danielpza
Copy link
Author

If I disable eglot-ensure it no longer complains :|

@joaotavora
Copy link
Owner

Yes, but can you get it to complain and generate a backtrace using toggle-debug-on-error and paste it here? Thanks

@danielpza
Copy link
Author

danielpza commented Apr 4, 2021

Are you using the very latest Eglot?

I installed it yesterday (not yesterday I see it's been there a while), I'll make sure it's up to date.

Can I get a backtrace?

is there a command for that or a buffer?

@danielpza
Copy link
Author

I see I'm too slow to respond and you actually responded before I could reply, I'll try that

@danielpza
Copy link
Author

I'm updating all my packages and it's taking a while, in the meantime this is the stacktrace I got:

Debugger entered--Lisp error: (wrong-type-argument flymake--backend-state nil)
  #<subr flymake--handle-report>(flymake-eslint--checker backend-token45 nil)
  apply(#<subr flymake--handle-report> (flymake-eslint--checker backend-token45 nil))
  #f(advice-wrapper :after #<subr flymake--handle-report> doom-modeline-update-flymake-icon)(flymake-eslint--checker backend-token45 nil)
  apply(#f(advice-wrapper :after #<subr flymake--handle-report> doom-modeline-update-flymake-icon) (flymake-eslint--checker backend-token45 nil))
  flymake--handle-report(flymake-eslint--checker backend-token45 nil)
  apply(flymake--handle-report flymake-eslint--checker backend-token45 nil)
  #f(compiled-function (&rest args) #<bytecode 0xd698b4eab600427>)(nil)
  #f(compiled-function (eslint-stdout) #<bytecode 0x1ef0e728213e5b8f>)(#<buffer  *flymake-eslint*>)
  #f(compiled-function (proc &rest ignored) #<bytecode -0x1d6545d48f23b74e>)(#<process flymake-eslint> "exited abnormally with code 2\n")

I'll report back after I'm done updating

@joaotavora
Copy link
Owner

Seems you are using flymake-eslint and eglot at the same time. Actually I happen to be using the same and used to get that error.

"updating all your packages" is likely not to bring in the latest Eglot version, which is what we wanted. But if you don't know how to update a single package from Melpa, doing the brute-force Doom dance is all we got. Maybe it'll pick up a new package. Anyway, good luck.

@joaotavora
Copy link
Owner

Actually I happen to be using the same and used to get that error.

(and I don't anymore in the very latest Eglot version)

@danielpza
Copy link
Author

"updating all your packages" is likely not to bring in the latest Eglot version

why not?

doing the brute-force Doom dance is all we got

I'm using straight in case that matters, I think doom also uses straight?

@danielpza
Copy link
Author

Got a similar error after updating:

Debugger entered--Lisp error: (wrong-type-argument flymake--backend-state nil)
  signal(wrong-type-argument (flymake--backend-state nil))
  #f(compiled-function (arg1 arg2 arg3 &rest rest) "Handle reports from BACKEND identified by TOKEN.\nBACKEND, REPORT-ACTION and EXPLANATION, and FORCE conform to the\ncalling convention described in\n`flymake-diagnostic-functions' (which see).  Optional FORCE says\nto handle a report even if TOKEN was not expected.  REGION is\na (BEG . END) pair of buffer positions indicating that this\nreport applies to that region." #<bytecode 0x19bbf2da544da5bd>)(flymake-eslint--checker backend-token45 nil)
  apply(#f(compiled-function (arg1 arg2 arg3 &rest rest) "Handle reports from BACKEND identified by TOKEN.\nBACKEND, REPORT-ACTION and EXPLANATION, and FORCE conform to the\ncalling convention described in\n`flymake-diagnostic-functions' (which see).  Optional FORCE says\nto handle a report even if TOKEN was not expected.  REGION is\na (BEG . END) pair of buffer positions indicating that this\nreport applies to that region." #<bytecode 0x19bbf2da544da5bd>) (flymake-eslint--checker backend-token45 nil))
  #f(advice-wrapper :after #f(compiled-function (arg1 arg2 arg3 &rest rest) "Handle reports from BACKEND identified by TOKEN.\nBACKEND, REPORT-ACTION and EXPLANATION, and FORCE conform to the\ncalling convention described in\n`flymake-diagnostic-functions' (which see).  Optional FORCE says\nto handle a report even if TOKEN was not expected.  REGION is\na (BEG . END) pair of buffer positions indicating that this\nreport applies to that region." #<bytecode 0x19bbf2da544da5bd>) doom-modeline-update-flymake-icon)(flymake-eslint--checker backend-token45 nil)
  apply(#f(advice-wrapper :after #f(compiled-function (arg1 arg2 arg3 &rest rest) "Handle reports from BACKEND identified by TOKEN.\nBACKEND, REPORT-ACTION and EXPLANATION, and FORCE conform to the\ncalling convention described in\n`flymake-diagnostic-functions' (which see).  Optional FORCE says\nto handle a report even if TOKEN was not expected.  REGION is\na (BEG . END) pair of buffer positions indicating that this\nreport applies to that region." #<bytecode 0x19bbf2da544da5bd>) doom-modeline-update-flymake-icon) (flymake-eslint--checker backend-token45 nil))
  flymake--handle-report(flymake-eslint--checker backend-token45 nil)
  apply(flymake--handle-report flymake-eslint--checker backend-token45 nil)
  #f(compiled-function (&rest args) #<bytecode 0x16fa69b1d517bce7>)(nil)
  #f(compiled-function (eslint-stdout) #<bytecode 0x1ea8a7c7163d378f>)(#<buffer  *flymake-eslint*>)
  #f(compiled-function (proc &rest ignored) #<bytecode -0x1b04c9b6cc26b70c>)(#<process flymake-eslint> "exited abnormally with code 2\n")

@joaotavora
Copy link
Owner

why not?

I've heard recently that Doom uses "version pinning" (in unrelated #596).

@danielpza
Copy link
Author

I'm using last commit from 3 days ago f930a09

@danielpza
Copy link
Author

I'm not using Doom btw in case it wasn't clear

@danielpza
Copy link
Author

ok seems like the deno issue got resolved and it has turned into a new one?

@joaotavora
Copy link
Owner

I saw doom-modeline-update-flymake-icon in your backtrace so I thought you were.

@joaotavora
Copy link
Owner

and it has turned into a new one?

Seems so, yes. But let's continue here. I'm afraid my last commit (which you are indeed using), has broken something.

Can you post a failing configuration that:

  • includes flymake-eslint
  • includes Eglot and basic deno setup
  • includes nothing else?

Thanks

@danielpza
Copy link
Author

danielpza commented Apr 4, 2021

This is my flymake-eslint + eglot configuration

(use-package flymake-eslint
  :straight t
  :config
  (add-hook 'typescript-mode-hook (lambda () (flymake-eslint-enable)))
  (add-hook 'js-mode-hook (lambda () (flymake-eslint-enable))))

(use-package eglot
  :straight t
  :hook ((js-mode typescript-mode) . 'eglot-ensure)
  :config
  (add-to-list 'eglot-server-programs '((js-mode typescript-mode) . (eglot-deno "deno" "lsp")))

  (defclass eglot-deno (eglot-lsp-server) ()
    :documentation "A custom class for deno lsp.")

  (cl-defmethod eglot-initialization-options ((server eglot-deno))
    "Passes through required deno initialization options"
    (list :enable t
	  :lint t)))

includes nothing else?

do you mean create an empty init.el with only above?

More:

I'm using typescript-mode alone for coloring:

(use-package typescript-mode
  :straight t
  :mode "\\.tsx\\'")

@danielpza
Copy link
Author

@joaotavora
Copy link
Owner

do you mean create an empty init.el with only above?

Yes, but maybe it's not necessary. I briefly reproduced your situation, but now I can't anymore. Are you sure everything works OK without the eglot-ensure?

@joaotavora
Copy link
Owner

joaotavora commented Apr 5, 2021

@danielpza I can't reproduce this. My guess it that you need to ensure you don't have stale .elc files.

I tried your sandbox, removed the deno line to use the default typescript-language-server. because I don't think this is related to the server at all (though you may want to post an event transcript for Deno/LSP debugging)

Another note. Are you sure your sandbox/setup is doing what you want? Without adding flymake to eglot-stay-out-of, it'll be hard to convince Eglot to let you use a second Flymake backend such as flymake-eslint.

On yet another note, there is no .eslintrc in your sandbox, so even if eslint did kick in, it would turn itself off immediately.

I recommend adding eglot-stay-out-of to your configuration somehow. Maybe this?

(use-package eglot
  :straight t
  :hook ((js-mode typescript-mode) . 'eglot-ensure)
  :config
  (add-hook 'js-mode-hook
            (lambda ()
              (setq-local eglot-stay-out-of '(flymake))
              (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)))
  
  (defclass eglot-deno (eglot-lsp-server) ()
    :documentation "A custom class for deno lsp.")

  (cl-defmethod eglot-initialization-options ((server eglot-deno))
    "Passes through required deno initialization options"
    (list :enable t
	  :lint t)))

@joaotavora joaotavora changed the title Cannot get deno lsp working: missing field 'enable' error Was: ~Cannot get deno lsp working: missing field 'enable' error~ Now: Flymake-bug with two backends Apr 5, 2021
@joaotavora joaotavora changed the title Was: ~Cannot get deno lsp working: missing field 'enable' error~ Now: Flymake-bug with two backends Flymake bug with two backends (Was: Cannot get deno lsp working: missing field 'enable' error) Apr 5, 2021
@joaotavora
Copy link
Owner

Any news on this @danielpza ? I've been using eslint and typescript-language-server just fine lately, so I'm going to take your silence to mean this is solved and close this. Of course, if it's not and you can work on the sandbox recipe so that it reproduces, we can reopen. In any case we can keep discussing.

@danielpza
Copy link
Author

I've been busy with work lately, I'll take some time to reproduce the issue in an isolated environment, we can keep it closed until then. Thanks for the work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants