Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Language server respond with error missing header in mac(Language server respond with error missing header in mac)
Language server respond with error missing header in mac [message #1857349] Wed, 01 February 2023 12:40 Go to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 56
Registered: May 2020
Member
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]

Report message to a moderator

Re: Language server failed to respond with error missing header in mac [message #1857350 is a reply to message #1857349] Wed, 01 February 2023 12:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
question:
- which xtext version
- lsp4j version
do you use?
and are you using websocket.
i never saw this problem on any of my examples on mac


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Language server failed to respond with error missing header in mac [message #1857351 is a reply to message #1857350] Wed, 01 February 2023 12:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you also please try https://github.com/cdietrich/xtext-languageserver-example-simple

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Language server failed to respond with error missing header in mac [message #1857352 is a reply to message #1857350] Wed, 01 February 2023 12:50 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 56
Registered: May 2020
Member
To answer your question:
- which xtext version: 2.29.0
- lsp4j version 0.19
and are you using websocket. I am running server in IO mode (basically with type script we are invoking server)

Sure will try your suggestion.



[Updated on: Wed, 01 February 2023 13:10]

Report message to a moderator

Re: Language server failed to respond with error missing header in mac [message #1857354 is a reply to message #1857352] Wed, 01 February 2023 12:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
no i am using io

run : { command: script },

the socket part is commented out

maybe you have something that spoils the io stream with unexpected messages
e.g. via some logging or println



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 01 February 2023 12:59]

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 Go to previous messageGo to next message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 56
Registered: May 2020
Member
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 #1857362 is a reply to message #1857361] Wed, 01 February 2023 17:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
can you please try my example with ./gradlew clean build startCode
you also might change the script to enable remote debugging and then remote debug what actually arrives.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 01 February 2023 17:51]

Report message to a moderator

Re: Language server failed to respond with error missing header in mac [message #1857363 is a reply to message #1857362] Wed, 01 February 2023 19:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
maybe you can also share a minimum reproducing example

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 01 February 2023 20:33]

Report message to a moderator

Re: Language server failed to respond with error missing header in mac [message #1857366 is a reply to message #1857364] Thu, 02 February 2023 06:25 Go to previous message
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 56
Registered: May 2020
Member
@Christian Dietrich Thank you will try your suggestion.
Previous Topic:Xtext 2.30.0.M2 is out
Next Topic:Data Type Rule
Goto Forum:
  


Current Time: Fri Apr 19 11:57:23 GMT 2024

Powered by FUDForum. Page generated in 0.01909 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top