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

Exception java.io.IOException: Stream Closed after account change with ongoing conversation #454

Closed
exigow opened this issue Feb 1, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@exigow
Copy link
Contributor

exigow commented Feb 1, 2024

Steps to reproduce:

  1. Ask Cody and wait for response.
  2. Go to settings and select different account - exception occurs.

NOTE: Account switch was from "free" to "enterprise", but this is probably not related.

024-02-01 13:10:05,192 [  35624]   WARN - o.e.l.j.RemoteEndpoint - Failed to send notification message.
org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: Stream Closed
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72)
	at org.eclipse.lsp4j.jsonrpc.TracingMessageConsumer.consume(TracingMessageConsumer.java:114)
	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.$Proxy133.configurationDidChange(Unknown Source)
	at com.sourcegraph.cody.config.notification.AccountSettingChangeListener$1.afterAction$lambda$0(AccountSettingChangeListener.kt:27)
	at com.sourcegraph.cody.agent.CodyAgentService$Companion$applyAgentOnBackgroundThread$1.invoke$lambda$0(CodyAgentService.kt:105)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:295)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: Stream Closed
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)
Caused by: java.io.IOException: Stream Closed

	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:69)
	... 16 more
@exigow exigow added the bug Something isn't working label Feb 1, 2024
@exigow exigow closed this as not planned Won't fix, can't repro, duplicate, stale Feb 1, 2024
@mkondratek
Copy link
Contributor

This issue is still with us. I've just reproduced it on d22e787 (a month ago) and f2c43c7 (today's main).

Today it looks like this:

2024-03-20 00:22:28,616 [ 116840]   WARN - #c.i.o.o.e.ConfigurableExtensionPointUtil - ignore deprecated groupId: language for id: preferences.language.Kotlin.scripting
2024-03-20 00:22:33,098 [ 121322]   WARN - o.e.l.j.RemoteEndpoint - Failed to send notification message.
org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.io.IOException: Stream Closed
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72)
	at org.eclipse.lsp4j.jsonrpc.TracingMessageConsumer.consume(TracingMessageConsumer.java:114)
	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.$Proxy145.configurationDidChange(Unknown Source)
	at com.sourcegraph.cody.config.notification.AccountSettingChangeListener$1.afterAction$lambda$0(AccountSettingChangeListener.kt:27)
	at com.sourcegraph.cody.agent.CodyAgentService$Companion.withAgent$lambda$2(CodyAgentService.kt:146)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:295)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: Stream Closed
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:69)
	... 16 more
2024-03-20 00:22:34,390 [ 122614]   WARN - #c.s.c.a.CodyAgentClient - Cody by Sourcegraph: █ VSCodeSecretStorage:getAccessToken: failed 
2024-03-20 00:22:34,637 [ 122861]   WARN - #c.s.c.a.CodyAgentClient - window.showErrorMessage: Sign in to Cody to get started
2024-03-20 00:22:34,637 [ 122861]   WARN - #c.s.c.a.CodyAgentClient - Cody by Sourcegraph: █ VSCodeSecretStorage:getAccessToken: failed 
2024-03-20 00:22:34,811 [ 123035]   WARN - #c.s.c.a.CodyAgentClient - Cody by Sourcegraph: █ GraphQLTelemetryExporter: telemetry: failed to evaluate server version: Error: accessing Sourcegraph GraphQL API: Error: HTTP status code 401: Private mode requires authentication.
 (https://sg02.sourcegraphcloud.com/.api/graphql?SiteProductVersion)
2024-03-20 00:22:34,951 [ 123175]   WARN - #c.s.c.a.CodyAgentClient - Cody by Sourcegraph: █ GraphQLTelemetryExporter: Error exporting telemetry events: Error: accessing Sourcegraph GraphQL API: Error: HTTP status code 401: Private mode requires authentication.
 (https://sg02.sourcegraphcloud.com/.api/graphql?RecordTelemetryEvents)

The last two (containing GraphQLTelemetryExporter) appear to me only when switching to sg02 instance.

@mkondratek mkondratek reopened this Mar 19, 2024
mkondratek added a commit that referenced this issue Mar 20, 2024
Before this PR it was possible to receive that IDE error:
```
java.lang.ArrayIndexOutOfBoundsException: No such child: 0
	at java.desktop/java.awt.Container.getComponent(Container.java:350)
	at com.sourcegraph.cody.chat.ui.MessagesPanel.addOrUpdateMessage(MessagesPanel.kt:30)
	at com.sourcegraph.cody.chat.ui.ChatPanel.addOrUpdateMessage(ChatPanel.kt:82)
	at com.sourcegraph.cody.chat.AgentChatSession.addMessageAtIndex(AgentChatSession.kt:260)
	at com.sourcegraph.cody.chat.AgentChatSession.receiveMessage$lambda$6$lambda$5(AgentChatSession.kt:178)
```

## Test plan
1. switch accounts
2. quickly write to the chat & send

expected:
the error does not appear (but most likely you will encounter the other
issue -
#454 (comment))
@mkondratek
Copy link
Contributor

most likely it's #1276. closing as a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants