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

Streaming Doesn't Work In Codeserver - Connect Protocol Error #200

Open
jlewi opened this issue Aug 20, 2024 · 8 comments
Open

Streaming Doesn't Work In Codeserver - Connect Protocol Error #200

jlewi opened this issue Aug 20, 2024 · 8 comments

Comments

@jlewi
Copy link
Owner

jlewi commented Aug 20, 2024

I was testing stateful/vscode-runme#1559
Inside codeserver.
Unary requests worked but the streaming completions didn't.

The RunMe output in vscode shows the following error

[2024-08-20T22:31:39.544Z] ERROR Runme: Error processing response ConnectError: [internal] Protocol error
[2024-08-20T22:31:39.544Z] INFO Runme: Stream closed due to error; resetting iterator

The request doesn't appear to ever hit the server.

@jlewi
Copy link
Owner Author

jlewi commented Aug 20, 2024

I'm not sure that streaming is supported on web.
connectrpc/connect-es#669

However, I'm not sure why that would be an issue here as I don't think the extension is actually running in the browser. If it was then I'm not sure how grpc would work.

@jlewi
Copy link
Owner Author

jlewi commented Aug 20, 2024

In the chrome console I see this error

[Extension Host] Error in PromiseIterator: ConnectError: [internal] Protocol error
	at ConnectError.from (/home/user/.local/share/code-server/extensions/stateful.runme-3.7.2-jlewi.4/out/extension.js:1303796:20)
	at connectErrorFromNodeReason (/home/user/.local/share/code-server/extensions/stateful.runme-3.7.2-jlewi.4/out/extension.js:1302558:39)
	at Promise.reject (/home/user/.local/share/code-server/extensions/stateful.runme-3.7.2-jlewi.4/out/extension.js:1303074:110)
	at ClientHttp2Stream.h2StreamError (/home/user/.local/share/code-server/extensions/stateful.runme-3.7.2-jlewi.4/out/extension.js:1302963:22)
	at ClientHttp2Stream.emit (node:events:518:28)
	at emitErrorNT (node:internal/streams/destroy:169:8)
	at emitErrorCloseNT (node:internal/streams/destroy:128:3)
	at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

@jlewi
Copy link
Owner Author

jlewi commented Aug 20, 2024

Filed: connectrpc/connect-es#1180

@jlewi
Copy link
Owner Author

jlewi commented Sep 5, 2024

This error seems like a similar problem in a different library
node-formidable/formidable#891

IUC that issue is indicating its a problem with the formidable library not supporting ClientHttp2Stream

I tried a regular non streaming error and I got a ConnectError although I didn't get the stacktrace in the console; probably because I have less logging on the vscode client side.

We are using HTTP2 here
https://github.com/stateful/vscode-runme/blob/c9d0be3d2ab8057a87e4a7c88c814d2891de433d/src/extension/ai/manager.ts#L86

So I suspect some library in code-server doesn't support HTTP2 for clients?

@jlewi
Copy link
Owner Author

jlewi commented Sep 5, 2024

@jlewi
Copy link
Owner Author

jlewi commented Sep 5, 2024

I think the bug might be in code-server
coder/code-server#6983

@jlewi
Copy link
Owner Author

jlewi commented Sep 5, 2024

We should try HTTP1. With HTTP1 we can't do bidirectional streaming. We could potentially support non-streaming or maybe unary streaming optionally. That might be good for the reasons mentioned in
https://connectrpc.com/docs/go/streaming

As mentioned there HTTP2 more tightly couples you to your networking infrastructure because all hops in the network path need to support it.

@jlewi
Copy link
Owner Author

jlewi commented Sep 10, 2024

See the comment in connectrpc/connect-es#1180.
The responder suggested it might an issue with configuring the client to use h2c (http in the clear; i.e. no TLS).

Here's where I create the transport.
https://github.com/stateful/vscode-runme/blob/3f2615bfc96fa107bed6d16dffb5d803b607af4b/src/extension/ai/manager.ts#L81

The link there
https://github.com/connectrpc/examples-es/blob/656f27bbbfb218f1a6dce2c38d39f790859298f1/vanilla-node/client.ts#L25
doesn't seem to point to code that used nodeOptions

IIRC I originally used nodeOptions and got a build error
stateful/vscode-runme#1475 (comment)
https://gist.github.com/jlewi/f3e4fb85b0b5d716f772aa898ea25fe7

nodeOptions was removed in this commit
stateful/vscode-runme@b70c22c

Here's an example of setting nodeOptions
https://github.com/connectrpc/connect-es/blob/ed63ceecfbf0188e709946b54e1ba3afdaba4972/packages/example/src/client.ts#L37

So we should try configuring nodeOptions and setting rejectUnauthorized to false and seeing if that fixes the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant