Closed elmisback closed 1 year ago
It's not related to stdout/stderr. That's an exception that happened in the didOpen
method and didn't put it into the opened document hash table. Any other later requests will produce a hash-ref
error.
A simple fix is to change local-require
to require
. Or waiting for it fixed by someone who really understands what happened :).
Thank you for having a look at this issue! While you might be right about the didOpen
issue, my problem was actually because xvfb-run
dumps stderr into stdout (!), so JSON-RPC was trying to read the report-error
output. https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1059947. I confirmed in a debugger that the mixed stream caused the JSON-RPC parser to miss the content-length header and then lose its place forever.
I fixed this by modifying xvfb-run
as suggested here: https://superuser.com/questions/1719253/xvfb-run-redirects-stdout-and-stderr-to-stdout-only. You may want to suggest this for other users who resort to using xvfb-run
for running headless as mentioned in (https://github.com/jeapostrophe/racket-langserver/issues/45).
tldr: Is there a way to have the language server not put errors into stdout/avoid exception printing when invoking the language server?
Hi, I'm a Magic Racket user (without much racket background, so there might be an easy fix) who is trying to figure out where a bug is coming from. I posted an issue in Magic Racket (https://github.com/Eugleo/magic-racket/issues/77#issuecomment-1301553286). It seems like stdout+stderr are getting mixed by the language server, and Magic Racket is unable to handle the error because of an uncatchable underlying exception in the jsonrpc parsing library (https://github.com/microsoft/vscode-languageserver-node/issues/870).
I have a program that looks like this:
This leads to a message from the language server with a mixture of racket error and jsonrpc data, which I caught in the VSCode extension debugger:
jsonrpc fails to find the Content-Length header in this buffer due to the error text, and after the first such error, all subsequent requests result in the same problem since there's extra stuff in the buffer and it's never cleared. So it seems like this is a problem with stdout getting mixed with stderr.
I tried setting
-W0
etc. in the langserver args to turn off stderr messages, but stuff still came through. I also tried redirection using a shell with2>/dev/null
and executing the langserver after loading an initial file that sets current-error-port to nowhere:with nostderr.rkt:
Those didn't work either. My understanding of how the VSCode language server actually runs the process based on the executable configuration above and how to configure ports in racket are weak, so there's probably something here that I'm missing. I was able to solve the issue by commenting out the relevant eprintf lines in a racket-langserver fork.
So basically it seems like what's needed is an option to turn off the error printing to the extent that it's possible, since Magic Racket doesn't have a way to gracefully handle printed errors until the PR for the issue I linked goes through (no activity since December 2021).