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

[Bug]: cannot use REST client vscode extension

Open pheman opened this issue 3 years ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

OS/Web Information

  • Web Browser: Chrome
  • Local OS: windows
  • Remote OS: centos
  • Remote Architecture: amd64
  • code-server --version: 4.4.0

REST Client extension(https://marketplace.visualstudio.com/items?itemName=humao.rest-client), the side window can pop after send a request but with no reply message.

image

Steps to Reproduce

  1. open code-server
  2. install extension, REST Client
  3. run command, send request. GET https://www.google.com

Expected

right side windows pop with reply message

Actual

right side windows pop with no message

Logs

No response

Screenshot/Video

image

Does this issue happen in VS Code or GitHub Codespaces?

  • [X] I cannot reproduce this in VS Code.
  • [X] I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • [X] I am using HTTPS.

Notes

No response

pheman avatar Aug 02 '22 12:08 pheman

Are there any logs in the browser you can share?

jsjoeio avatar Aug 03 '22 19:08 jsjoeio

I have the same issue (also with some other extensions) when code-server is exposed externally (http, https, w/ or w/o password). However, it works when using 127.0.0.1 (with SSH tunnel for example).

Seems to be related to sha-256 calculations... I have this error message in the browser logs : ERR Can't compute sha-256: t@http://10...*:8081/static/out/vs/workbench/workbench.web.main.js:798:15149

adeleporte avatar Aug 25 '22 13:08 adeleporte

Interesting 🤔

Running locally on localhost:8080, I can't reproduce.

image

I tested it by exposing via ngrok and it works as expected as well:

image

If you could paste a screenshot or the entire browser logs, that would help.

jsjoeio avatar Aug 25 '22 15:08 jsjoeio

Sure: Screenshot 2022-08-25 at 19 06 33

Browser logs:

An iframe which has both allow-scripts and allow-same-origin for its sandbox attribute can remove its sandboxing. 192.168.144.17:8080
  ERR Can't compute sha-256: t@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:798:15149
F@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1351:9435
_createInstance@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:607:1332
createInstance@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:607:773
createWebviewElement@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1351:21856
show@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1291:41076
claim@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1291:39597
claimWebview@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1755:82968
setInput@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1755:82879
async*doSetInput@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:2656:26948
doOpenEditor@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:2656:25324
openEditor@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:2656:24950
doShowEditor/ne<@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:2861:17281
doShowEditor@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:2861:17541
doOpenEditor@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:2861:17014
openEditor@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:2861:15746
openEditor@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:2683:24713
async*createWebview@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1963:3496
$createWebviewPanel@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1963:7430
_doInvokeHandler@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1734:13103
_invokeHandler@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1734:12787
_receiveRequest@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1734:11449
_receiveOneMessage@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1734:10127
h/<@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:1734:8236
invoke@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:67:145
fire@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:67:1856
fire@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:83:18792
_receiveMessage@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:83:23373
f/<@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:83:20907
invoke@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:67:145
fire@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:67:1856
acceptChunk@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:83:15623
s/<@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:83:14753
onData/<@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:617:42227
invoke@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:67:145
fire@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:67:1856
E/this._fileReader.onload@http://192.168.144.17:8080/static/out/vs/workbench/workbench.web.main.js:617:40157
log.ts:313:11
Uncaught (in promise) Error: Can't compute sha-256
    t webview.ts:11
    F webviewElement.ts:177
    _createInstance instantiationService.ts:110
    createInstance instantiationService.ts:76
    createWebviewElement webviewService.ts:52
    show overlayWebview.ts:163
    claim overlayWebview.ts:102
    claimWebview webviewEditor.ts:158
    setInput webviewEditor.ts:149
    doSetInput editorPanes.ts:281
    doOpenEditor editorPanes.ts:150
    openEditor editorPanes.ts:118
    ne editorGroupView.ts:1096
    doShowEditor editorGroupView.ts:1120
    doOpenEditor editorGroupView.ts:1078
    openEditor editorGroupView.ts:985
    openEditor editorService.ts:535
    createWebview webviewWorkbenchService.ts:231
    $createWebviewPanel mainThreadWebviewPanels.ts:168
    _doInvokeHandler rpcProtocol.ts:473
    _invokeHandler rpcProtocol.ts:458
    _receiveRequest rpcProtocol.ts:374
    _receiveOneMessage rpcProtocol.ts:296
    h rpcProtocol.ts:161
    invoke event.ts:569
    fire event.ts:736
    fire ipc.net.ts:638
    _receiveMessage ipc.net.ts:958
    f ipc.net.ts:831
    invoke event.ts:569
    fire event.ts:736
    acceptChunk ipc.net.ts:382
    s ipc.net.ts:338
    onData browserSocketFactory.ts:230
    invoke event.ts:569
    fire event.ts:736
    onload browserSocketFactory.ts:91
webview.ts:11:8
  ERR [Extension Host] (node:1100) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created) log.ts:313:11
[Extension Host] (node:1100) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created) console.ts:137:34

adeleporte avatar Aug 25 '22 17:08 adeleporte

Very helpful! Looks like your error is originating here:

https://github.com/microsoft/vscode/blob/main/src/vs/workbench/browser/webview.ts#L11

Can you try using something like ngrok and seeing if you still get the error?

If you do get the error, not related to HTTPS If you don't, probably related toHTTPS

jsjoeio avatar Aug 29 '22 16:08 jsjoeio

Thanks for the update. Unfortunately, I can't use ngrok (company policy).

But there is a very simple way to reproduce it, by using the docker image:

docker run -d -p 0.0.0.0:8080:8080 --rm codercom/code-server

If I access to http://127.0.0.1:8080, or http://localhost:8080, everything is working fine. If I access to the docker host directly, let's say http://172.20.5.109:8080, the extension is broken.

This docker image doesn't use https, so I would say that the issue is not related to https.

Thanks for looking at this issue!

adeleporte avatar Aug 29 '22 17:08 adeleporte

If I access to the docker host directly, let's say http://172.20.5.109:8080/, the extension is broken.

That means you're not using HTTPS so service workers won't work so the extension shouldn't work. I think that proves that this is related to HTTPS then. And I don't think there's any way to work around this unfortunately.

jsjoeio avatar Aug 29 '22 17:08 jsjoeio

Hum interesting..

I have created a new "https" docker image with this Docker file:

FROM codercom/code-server:latest COPY config.yaml /home/coder/.config/code-server/config.yaml ENTRYPOINT ["/usr/bin/entrypoint.sh", "."]

and this config file :

bind-addr: 0.0.0.0:443 auth: password password: test cert: true

docker run -d -p 0.0.0.0:443:443 --rm adeleporte/httpscoder

And this time, it does work with any address/fqdn...

I will re-check with my previous configuration. Thanks!

adeleporte avatar Aug 29 '22 17:08 adeleporte

Well that is certainly good news to my Monday! Sounds good!

jsjoeio avatar Aug 29 '22 18:08 jsjoeio

Closing since it seems this is solved?

code-asher avatar Mar 12 '24 19:03 code-asher