Language server respond with error missing header in mac [message #1857349] |
Wed, 01 February 2023 12:40  |
Eclipse User |
|
|
|
I have installed vscode extension in mac book, language server responded with error missing header.
I found this github issue https://github.com/eclipse/lsp4j/issues/210 with the same stack trace.
We have a server which is IO mode.
Why i am facing this issue in macbook only? It works in windows.
It bits strange for me why language client will send request without header.
Installed extension in vscode version 1.74.3(Both windows and mac have same vscode)
Any hint and suggestions it would be great help.
Thanks
Nagaraj
[Updated on: Wed, 01 February 2023 12:47] by Moderator Report message to a moderator
|
|
|
|
|
|
|
Re: Language server failed to respond with error missing header in mac [message #1857361 is a reply to message #1857354] |
Wed, 01 February 2023 16:54   |
Eclipse User |
|
|
|
I am new bit new to mac book, for mac extension i am using shell script to start server if i change shell script permission(chmod 755) to read write and execute i got below error.
023-02-01 16:34:31.513 [error] Error: Header must provide a Content-Length property.
at StreamMessageReader.onData (/Users/ngk/.vscode/extensions/myextension-mac-extension-0.0.2/node_modules/vscode-jsonrpc/lib/common/messageReader.js:138:27)
at Socket.<anonymous> (/Users/ngk/.vscode/extensions/myextension-mac-extension-0.0.2/node_modules/vscode-jsonrpc/lib/common/messageReader.js:122:18)
at Socket.emit (node:events:526:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
if i don't change permission i am getting notification from server like ''Request has failed ''
something is going wrong with vscode extension execution.
is it related to some permission issues which is causing extension to not work in macbook.
any suggestions since i don't have my workspace setup in macbook i am just relying on console logs of vscode.
some how io steam is getting spoiled or request formation from client is not correct or some permissions issue .
I am launching vscode from download folder and installed extension.
every bit of code is same except shell script to launch server (No issue in windows )
|
|
|
|
|
Re: Language server failed to respond with error missing header in mac [message #1857364 is a reply to message #1857363] |
Wed, 01 February 2023 20:08   |
Eclipse User |
|
|
|
you might also alter the launch script to do
-log debug -trace (dont know to what . dir this is written to)
set -- \
-classpath "$CLASSPATH" \
org.eclipse.xtext.ide.server.ServerLauncher \
"-log" "debug" "-trace"
may log into the folder/project you open in code to test.
so you might use this
launcher class instead
package org.xtext.example.mydsl.ide;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.concurrent.Future;
import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.services.LanguageClient;
import org.eclipse.xtext.ide.server.LanguageServerImpl;
import org.eclipse.xtext.ide.server.LaunchArgs;
import org.eclipse.xtext.ide.server.ServerModule;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.InputOutput;
import com.google.common.base.Objects;
import com.google.common.io.ByteStreams;
import com.google.inject.Guice;
import com.google.inject.Inject;
public class MyServerLauncher {
public static final String LOG = "-log";
public static final String TRACE = "-trace";
public static final String NO_VALIDATE = "-noValidate";
public static void main(String[] args) {
launch(MyServerLauncher.class.getName(), new String[] {"-log", "debug", "-trace"}, new ServerModule());
}
public static void launch(String prefix, String[] args, com.google.inject.Module... modules) {
LaunchArgs launchArgs = createLaunchArgs(prefix, args);
MyServerLauncher launcher = Guice.createInjector(modules).<MyServerLauncher>getInstance(MyServerLauncher.class);
launcher.start(launchArgs);
}
@Inject
private LanguageServerImpl languageServer;
public void start(LaunchArgs args) {
try {
InputOutput.println("Xtext Language Server is starting.");
Launcher<LanguageClient> launcher = Launcher.createLauncher(languageServer,
LanguageClient.class, args.getIn(), args.getOut(), args.isValidate(), args.getTrace());
languageServer.connect(launcher.getRemoteProxy());
Future<Void> future = launcher.startListening();
InputOutput.println("Xtext Language Server has been started.");
while (!future.isDone()) {
Thread.sleep(10_000L);
}
} catch (InterruptedException e) {
throw Exceptions.sneakyThrow(e);
}
}
public static LaunchArgs createLaunchArgs(String prefix, String[] args) {
LaunchArgs launchArgs = new LaunchArgs();
launchArgs.setIn(System.in);
launchArgs.setOut(System.out);
redirectStandardStreams(prefix, args);
launchArgs.setTrace(getTrace(args));
launchArgs.setValidate(shouldValidate(args));
return launchArgs;
}
public static PrintWriter getTrace(String[] args) {
if (shouldTrace(args)) {
return createTrace();
}
return null;
}
public static PrintWriter createTrace() {
return new PrintWriter(System.out);
}
public static void redirectStandardStreams(String prefix, String[] args) {
if (shouldLogStandardStreams(args)) {
logStandardStreams(prefix);
} else {
silentStandardStreams();
}
}
public static boolean shouldValidate(String[] args) {
return !testArg(args, MyServerLauncher.NO_VALIDATE);
}
public static boolean shouldTrace(String[] args) {
return testArg(args, MyServerLauncher.TRACE);
}
public static boolean shouldLogStandardStreams(String[] args) {
return testArg(args, MyServerLauncher.LOG, "debug");
}
public static boolean testArg(String[] args, String... values) {
for (String arg : args) {
if (testArg(arg, values)) {
return true;
}
}
return false;
}
public static boolean testArg(String arg, String... values) {
for(String value : values) {
if (Objects.equal(value, arg)) {
return true;
}
}
return false;
}
public static void logStandardStreams(String prefix) {
try {
FileOutputStream stdFileOut = new FileOutputStream(System.getProperty("user.home")+"/"+prefix + "-debug.log");
redirectStandardStreams(stdFileOut);
} catch (IOException e) {
throw Exceptions.sneakyThrow(e);
}
}
public static void silentStandardStreams() {
redirectStandardStreams(silentOut());
}
public static void redirectStandardStreams(OutputStream out) {
redirectStandardStreams(silentIn(), out);
}
public static void redirectStandardStreams(InputStream in, OutputStream out) {
System.setIn(in);
System.setOut(new PrintStream(out));
}
public static OutputStream silentOut() {
return ByteStreams.nullOutputStream();
}
public static InputStream silentIn() {
return new ByteArrayInputStream(new byte[0]);
}
}
which will log to ~/org.xtext.example.mydsl.ide.MyServerLauncher-debug.log
[Updated on: Wed, 01 February 2023 20:33] by Moderator Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04586 seconds