code-server icon indicating copy to clipboard operation
code-server copied to clipboard

ClientHttp2Stream.h2StreamError from extension in code-server

Open jlewi opened this issue 1 year ago • 8 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

OS/Web Information

  • Web Browser: Chrome
  • Local OS: MacOS
  • Remote OS: MacOs
  • Remote Architecture: Arm
  • code-server --version: 4.92.2 de65bfc9477f61bc22d0b1a23085d1f18bb25202 with Code 1.92.2

Steps to Reproduce

  1. Run code-server
  2. To install the RunMe VSCode Extension
  3. Download and configure Foyle (www.foyle.io)
  4. Run foyle serve
  5. In RunMe enable AI Auto Cell Option
  6. Open a markdown document as a RunMe notebook
  7. Start typing in a markdown cell to trigger an RPC to Foyle

Expected

Foyle should generate a completion and insert it a cell into the notebook.

Actual

We get an error in vscode.

In the RunMe Output window we see the error

[2024-09-05T15:02:20.696Z] ERROR Runme(AIGenerate): AI Generate request failed ConnectError: [internal] Protocol error

Chrome console shows the following 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)

I believe the error indicates there is lack of support for HTTP2 clients. It works in native vscode so I suspect the problem must be something with code-server.

Logs

No response

Screenshot/Video

No response

Does this bug reproduce in native VS Code?

No, this works as expected in native VS Code

Does this bug reproduce in GitHub Codespaces?

I did not test GitHub Codespaces

Are you accessing code-server over a secure context?

  • [ ] I am using a secure context.

Notes

No response

jlewi avatar Sep 05 '24 15:09 jlewi

Is it trying to reach out to localhost or something? Some extensions do this but of course that will not work in the web, they need to use the proxy to get to the port.

We should test in Codespaces though, if it is broken there then it will either be an issue with VS Code or the plugin.

code-asher avatar Sep 05 '24 19:09 code-asher

Actually it must be using the proxy, right? Otherwise the error would be "connection refused " or something.

I think the package we use for proxying does not support HTTP/2.

code-asher avatar Sep 05 '24 19:09 code-asher

Here is the upstream issue: https://github.com/http-party/node-http-proxy/issues/1237

Maybe there is a different package we can use :thinking:

code-asher avatar Sep 05 '24 19:09 code-asher

@code-asher Thank you for replying.

Is it trying to reach out to localhost or something? Some extensions do this but of course that will not work in the web, they need to use the proxy to get to the port.

Yes. It is trying to reach out to local host. Specifically http://localhost:8877/api.

I'm unfamiliar with the architecture of code-server; can you explain where a proxy gets used? I thought code-server had a server with a thin web-client. I thought the server is where the vscode extension host is running and where the RPC should be coming from. code-server is running on my laptop and so I would expect it be able to access localhost.

jlewi avatar Sep 05 '24 23:09 jlewi

Yup, code-server is mostly just a thin web client around VS Code, but it also has a simple reverse proxy. The reason being that extensions (like this) spin up their own server on some port (8877 in this case) and they need a way to access that from the local browser to the remote (where localhost will not work). The proxy is used when an extension calls asExternalUri.

So it can be that either it is trying to reach localhost:8877 from the browser and it needs to be changed to use asExternalUir, or is it already using that but our proxy does not support http/2.

code-asher avatar Sep 10 '24 16:09 code-asher

Ah but yeah in your case, if it is running locally, accessing localhost will work and that means our proxy is not involved, so maybe this is some other issue entirely? It should work the same as native VS Code in that case.

code-asher avatar Sep 10 '24 16:09 code-asher

If the request runs from the browser, maybe there is some difference in the browser vs Electron with regards to http/2, so something to look into might be whether the package that is providing the http/2 connection has browser support.

If the request runs from Node though, I am not sure. The only difference there from native VS Code is plain Node vs Electron but I am not sure that could be making a difference here.

code-asher avatar Sep 10 '24 17:09 code-asher

Maybe there is a different package we can use 🤔

  • https://github.com/unjs/httpxy
  • https://github.com/sagemathinc/http-proxy-3

Both rewritten in Typescript. No HTTP/2 support, either.

And most likely not ready for production use.

benz0li avatar May 08 '25 04:05 benz0li