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

code-server v4 unable to load resources (e.g. new theme) -- requesting to port 80? #4608

Closed
drmrbrewer opened this issue Dec 11, 2021 · 7 comments · Fixed by #4631
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@drmrbrewer
Copy link

I'm getting the following error in the console when trying to load a new theme (in a fresh v4 installation):

  GET https://code-server.mydomain.com:80/vscode-remote-resource?path=%2Fusr%2Flib%2Fcode-server%2Fvendor%2Fmodules%2Fcode-oss-dev%2Fextensions%2Ftheme-defaults%2Fthemes%2Fdark_plus.json&tkn=0000 net::ERR_SSL_PROTOCOL_ERROR

  ERR Unable to load vscode-remote://code-server.mydomain.com:80/usr/lib/code-server/vendor/modules/code-oss-dev/extensions/theme-defaults/themes/dark_plus.json: Failed to fetch: Error: Unable to load vscode-remote://code-server.mydomain.com:80/usr/lib/code-server/vendor/modules/code-oss-dev/extensions/theme-defaults/themes/dark_plus.json: Failed to fetch
	at https://code-server.mydomain.com/static/out/vs/workbench/workbench.web.api.js:1926:79062
	at async Z.restoreColorTheme (https://code-server.mydomain.com/static/out/vs/workbench/workbench.web.api.js:1926:79687)

My installation is in this context: #4529 (comment) (just replacing curl install.sh | sh with curl install.sh | sh -s -- --version=4.0.0).

I also have the following ENTRYPOINT (i.e. binding to 8443 rather than 8080):

ENTRYPOINT [ "code-server", "/root/workspace", "--bind-addr", "0.0.0.0:8443" ]

It all seems to fire up just fine with v4... just not able to change theme for a start.

I'm also seeing the following (not really doing anything to prompt it):

  ERR Unable to load and parse grammar for scope source.json.comments from vscode-remote://code-server.mydomain.com:80/usr/lib/code-server/vendor/modules/code-oss-dev/extensions/json/syntaxes/JSONC.tmLanguage.json TypeError: Failed to fetch
	at v.readExtensionResource (extensionResourceLoaderService.ts:46)
	at Object.readFile (abstractTextMateService.ts:246)
	at Object.loadGrammar (TMGrammarFactory.ts:53)
	at e.<anonymous> (main.js:107)
	at main.js:46
	at Object.next (main.js:27)
	at main.js:21
	at new Promise (<anonymous>)
	at i (main.js:17)
	at e._doLoadSingleGrammar (main.js:103)
log.ts:313   ERR No grammar provided for <source.json.comments>: Error: No grammar provided for <source.json.comments>
	at d (https://code-server.mydomain.com/static/node_modules/vscode-textmate/release/main.js:1:3170)
	at e.processQueue (https://code-server.mydomain.com/static/node_modules/vscode-textmate/release/main.js:1:2533)
	at e.<anonymous> (https://code-server.mydomain.com/static/node_modules/vscode-textmate/release/main.js:1:30634)
	at https://code-server.mydomain.com/static/node_modules/vscode-textmate/release/main.js:1:28678
	at Object.next (https://code-server.mydomain.com/static/node_modules/vscode-textmate/release/main.js:1:28783)
	at s (https://code-server.mydomain.com/static/node_modules/vscode-textmate/release/main.js:1:27497)
@drmrbrewer drmrbrewer changed the title code-server v4 unable to load resources (requesting to port 80?) code-server v4 unable to load resources (e.g. new theme) -- requesting to port 80? Dec 11, 2021
@drmrbrewer
Copy link
Author

drmrbrewer commented Dec 11, 2021

I suspect that this is a duplicate of: #4607 and also #4604

@drmrbrewer
Copy link
Author

When I access code-server via http rather than https, switching theme does work... though the theme previews are not shown so it's a case of choosing the theme via "Browse Color Themes".

@jsjoeio jsjoeio added the needs-investigation This issue needs to be further investigated label Dec 13, 2021
@jsjoeio jsjoeio modified the milestones: 4.0.1, 4.0.0 Dec 13, 2021
@drmrbrewer
Copy link
Author

drmrbrewer commented Dec 13, 2021

@jsjoeio @code-asher I've set up a demo deployment of code-server v4 over here so that you can play around with it. Password is issue-4608.

@code-asher code-asher self-assigned this Dec 13, 2021
@code-asher code-asher modified the milestones: 4.0.0, 4.0.1 Dec 13, 2021
@code-asher
Copy link
Member

Thank you for the bug report and the demo! Will try to fix this asap.

@drmrbrewer
Copy link
Author

drmrbrewer commented Dec 13, 2021

This is the Dockerfile used to build the code-server image (it's basically what @code-asher suggested here but with a few extra bits and pieces):

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
 && apt-get install -y curl \
 && curl -fsSL https://code-server.dev/install.sh | sh -s -- --version=4.0.0 \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*
RUN apt-get update \
 && apt-get install -y \
	git \
	zip \
	tzdata \
	iputils-ping \
	nano \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get update && apt-get install -y nodejs \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*
RUN sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/g' /root/.bashrc
RUN mkdir -p /root/workspace /root/.ssh
EXPOSE 8443
ENTRYPOINT [ "code-server", "/root/workspace", "--bind-addr", "0.0.0.0:8443" ]

@code-asher code-asher added bug Something isn't working and removed needs-investigation This issue needs to be further investigated labels Dec 13, 2021
code-asher added a commit to coder/vscode that referenced this issue Dec 14, 2021
Trying to determine the remote authority on the backend is brittle
because it does not work behind reverse proxies unless they send the
right headers containing information about the proxied source.

We could require users add the relevant configuration or provide the
remote authority via a flag but neither are user-friendly options.

We can make it work out of the box by changing the frontend to make
requests to its current address (which is what we try to set the remote
authority to anyway).  This actually already happens for the most part
except in some UI and logs although recent issues suggest there might be
other problems which should be entirely resolved by setting this on the
frontend.

In other words, the remote authority we set on the backend should never
be used so we set it to something invalid to ensure we notice (the
alternative is to rip it out but that is probably a bigger patch thus
generating more conflicts).

One scenario where we might want to set the remote authority from the
backend is if the frontend is served from a different location than the
backend but that is not supported behavior at the moment.  Even if we
did support this we still cannot determine the authority from the
backend (even for non-proxy scenarios in this case) and would need to
add a flag for it so this change would still be necessary.

coder/code-server#4604
coder/code-server#4607
coder/code-server#4608
@code-asher code-asher modified the milestones: 4.0.1, 4.0.0 Dec 14, 2021
code-asher added a commit to code-asher/code-server that referenced this issue Dec 15, 2021
Fixes coder#3410
Fixes coder#4604
Fixes coder#4607
Fixes coder#4608
Fixes coder#4609

Also has the foundation for
coder#4619.
jsjoeio pushed a commit that referenced this issue Dec 15, 2021
Fixes #3410
Fixes #4604
Fixes #4607
Fixes #4608
Fixes #4609

Also has the foundation for
#4619.
ZauberNerd pushed a commit to ZauberNerd/vscode that referenced this issue Dec 23, 2021
Trying to determine the remote authority on the backend is brittle
because it does not work behind reverse proxies unless they send the
right headers containing information about the proxied source.

We could require users add the relevant configuration or provide the
remote authority via a flag but neither are user-friendly options.

We can make it work out of the box by changing the frontend to make
requests to its current address (which is what we try to set the remote
authority to anyway).  This actually already happens for the most part
except in some UI and logs although recent issues suggest there might be
other problems which should be entirely resolved by setting this on the
frontend.

In other words, the remote authority we set on the backend should never
be used so we set it to something invalid to ensure we notice (the
alternative is to rip it out but that is probably a bigger patch thus
generating more conflicts).

One scenario where we might want to set the remote authority from the
backend is if the frontend is served from a different location than the
backend but that is not supported behavior at the moment.  Even if we
did support this we still cannot determine the authority from the
backend (even for non-proxy scenarios in this case) and would need to
add a flag for it so this change would still be necessary.

coder/code-server#4604
coder/code-server#4607
coder/code-server#4608
ZauberNerd pushed a commit to ZauberNerd/vscode that referenced this issue Dec 23, 2021
Trying to determine the remote authority on the backend is brittle
because it does not work behind reverse proxies unless they send the
right headers containing information about the proxied source.

We could require users add the relevant configuration or provide the
remote authority via a flag but neither are user-friendly options.

We can make it work out of the box by changing the frontend to make
requests to its current address (which is what we try to set the remote
authority to anyway).  This actually already happens for the most part
except in some UI and logs although recent issues suggest there might be
other problems which should be entirely resolved by setting this on the
frontend.

In other words, the remote authority we set on the backend should never
be used so we set it to something invalid to ensure we notice (the
alternative is to rip it out but that is probably a bigger patch thus
generating more conflicts).

One scenario where we might want to set the remote authority from the
backend is if the frontend is served from a different location than the
backend but that is not supported behavior at the moment.  Even if we
did support this we still cannot determine the authority from the
backend (even for non-proxy scenarios in this case) and would need to
add a flag for it so this change would still be necessary.

coder/code-server#4604
coder/code-server#4607
coder/code-server#4608
ZauberNerd pushed a commit to ZauberNerd/vscode that referenced this issue Dec 23, 2021
Trying to determine the remote authority on the backend is brittle
because it does not work behind reverse proxies unless they send the
right headers containing information about the proxied source.

We could require users add the relevant configuration or provide the
remote authority via a flag but neither are user-friendly options.

We can make it work out of the box by changing the frontend to make
requests to its current address (which is what we try to set the remote
authority to anyway).  This actually already happens for the most part
except in some UI and logs although recent issues suggest there might be
other problems which should be entirely resolved by setting this on the
frontend.

In other words, the remote authority we set on the backend should never
be used so we set it to something invalid to ensure we notice (the
alternative is to rip it out but that is probably a bigger patch thus
generating more conflicts).

One scenario where we might want to set the remote authority from the
backend is if the frontend is served from a different location than the
backend but that is not supported behavior at the moment.  Even if we
did support this we still cannot determine the authority from the
backend (even for non-proxy scenarios in this case) and would need to
add a flag for it so this change would still be necessary.

coder/code-server#4604
coder/code-server#4607
coder/code-server#4608
@drmrbrewer
Copy link
Author

Having now tried v4.0.1 I can confirm that this issue appears to be resolved... but you knew that already! Nice work!

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 7, 2022

Hooray! Thank you for confirming @drmrbrewer 🙌

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

Successfully merging a pull request may close this issue.

3 participants