glsp icon indicating copy to clipboard operation
glsp copied to clipboard

Broken Pipe exception when client disconnects while server is still busy

Open CamilleLetavernier opened this issue 5 years ago • 1 comments

This exception often happens when the client disconnects (i.e. closes browser tab):

WARNING: Failed to send notification message.
org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: java.io.IOException: Broken pipe
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.notify(RemoteEndpoint.java:126)
	at org.eclipse.lsp4j.jsonrpc.services.EndpointProxy.invoke(EndpointProxy.java:88)
	at com.sun.proxy.$Proxy42.process(Unknown Source)
	at org.eclipse.glsp.server.actionhandler.ClientActionHandler.send(ClientActionHandler.java:57)
	at org.eclipse.glsp.server.actionhandler.ClientActionHandler.execute(ClientActionHandler.java:51)
	at org.eclipse.glsp.server.action.DefaultActionDispatcher.runAction(DefaultActionDispatcher.java:210)
	at org.eclipse.glsp.server.action.DefaultActionDispatcher.handleMessage(DefaultActionDispatcher.java:180)
	at org.eclipse.glsp.server.action.DefaultActionDispatcher.handleNextMessage(DefaultActionDispatcher.java:165)
	at org.eclipse.glsp.server.action.DefaultActionDispatcher.runThread(DefaultActionDispatcher.java:152)
	at java.base/java.lang.Thread.run(Thread.java:834)

The ActionDispatcher listens to client lifecycle, but if it's already processing a message while this happens, responses to this message may still be sent to the client via the ClientActionHandler. This handler should probably also listen to Client lifecycle, and stop sending messages after the client disconnects.

CamilleLetavernier avatar Oct 02 '20 08:10 CamilleLetavernier

Yes good idea to add a lifecycle listener and stop sending if the client has disconnected. Can you please do that @CamilleLetavernier ?

planger avatar Jan 28 '21 10:01 planger