Skip to content

[v2] Code Runner and Redhat Java extensions cannot run code in EC2 when Chrome or Safari are used #1136

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

Closed
emil-simeonov-se opened this issue Nov 1, 2019 · 8 comments
Labels
bug Something isn't working

Comments

@emil-simeonov-se
Copy link

emil-simeonov-se commented Nov 1, 2019

  • code-server version:
info  2.1665-vsc1.39.2
info  3d5db8313a91f80dfc402450fd117b4e63f7711e
info  x64

N.B. I am not sure that this issue is strictly related to the specific version of code-server. I had a similar experience with just running Java code from within the IDE on an EC2 VM even before. Now I can confirm that code snippets also misbehave.

  • OS Version: Ubuntu VM hosted by Amazon EC2, client machine is macOS Catalina with latest Firefox, Chrome, and Safari installed.

Description

I have built a Docker image with Java support (https://github.com/redhat-developer/vscode-java) which is also able to execute code snippets from many other languages (https://github.com/formulahendry/vscode-code-runner). Containers based on this image work equally well when run on my local macOS machine with latest versions of Firefox, Chrome, and Safari.

I run a container based on this same image on a VM in Amazon EC2. Using Firefox I am able to run code snippets supported by the code-runner extension and use vscode-java to execute Java applications or tests from within the VS Code.

Using the Chrome or Safari web browsers to connect to the same container, none of those worked. I see that extensions are being activated but nothing really happens when trying to execute code snippets or Java code.

Maybe there is something to be configured. I am not sure. Any recommendation how to get Chrome (and potentially Safari) working against a Docker container run on an EC2 VM would be highly appreciated.

Steps to Reproduce

  1. Launch a t2.large Ubuntu VM in EC2.
  2. Run a docker container which supports Java (vscode-java) and/or running code snippets (code-runner) on top of this VM.
  3. Use Firefox to execute code snippets or Java code from within the IDE. Should work.
  4. Use Chrome or Safari to execute code snippets or Java code from within the IDE. Most likely without success.
@emil-simeonov-se emil-simeonov-se added the bug Something isn't working label Nov 1, 2019
@emil-simeonov-se emil-simeonov-se changed the title [v2] Code Runner and Redhat Java extensions cannot run code [v2] Code Runner and Redhat Java extensions cannot run code in EC2 Nov 1, 2019
@emil-simeonov-se emil-simeonov-se changed the title [v2] Code Runner and Redhat Java extensions cannot run code in EC2 [v2] Code Runner and Redhat Java extensions cannot run code in EC2 when Chrome or Safari are used Nov 1, 2019
@code-asher
Copy link
Member

I'll try this out as soon as I can but in the meantime here's a wild shot in the dark: is the URL somehow HTTP for Chrome/Safari but not Firefox? I've seen issues running tasks when service workers aren't available (which happens on HTTP).

@emil-simeonov-se
Copy link
Author

Negative. The URL is always a http://... for all browsers. Currently, it's not secured in any way as I am running a multi-stage MVP and SSL would be a bit too much for the current stage. I also just spin up the container. There is no load balancer/reverse proxy whatsoever in between.

By the way, I can share a Dockerfile that may save few minutes on your side and just give you the opportunity to play around and observe. Would that help?

@code-asher
Copy link
Member

Yeah, that sounds great.

@emil-simeonov-se
Copy link
Author

So here is the content of the Dockerfile. Few things to keep in mind:

  1. The Redhat Java language support extension fails to activate (something which I don't face as an issue). Might be related to the archtetype used for project creation.
  2. [EC2] Right click on the org.example.App Java file and select Run Code. This will use the code-runner extension or create a groovy file and do the same. This will work well in Firefox (at least you will see that some class is not found). Nothing will happen once you try it in Chrome, Chromium or Safari.
  3. [local machine] The same flow will work with all browsers.
FROM codercom/code-server:latest

ENV PASSWORD=init1234

RUN sudo apt-get update && \
    sudo apt-get install unzip zip curl openjdk-8-jdk maven -y

ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

RUN curl -s get.sdkman.io | bash && \
    /bin/bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install groovy"

# Set up maven project 
WORKDIR /home/coder
RUN mvn -B archetype:generate \
        -DarchetypeGroupId=org.apache.maven.archetypes \
        -DarchetypeArtifactId=maven-archetype-simple \
        -DarchetypeVersion=1.4 \
        -DgroupId=org.example \
        -DartifactId=my-project \
        -Dversion=1.0-SNAPSHOT

# Install extensions
RUN code-server --install-extension marlon407.code-groovy && \
    code-server --install-extension formulahendry.code-runner && \
    code-server --install-extension vscjava.vscode-java-pack

WORKDIR /home/coder/my-project

RUN mvn test

ENTRYPOINT ["dumb-init", "code-server", "--host", "0.0.0.0", "/home/coder/my-project"]

@code-asher
Copy link
Member

code-asher commented Nov 1, 2019

I haven't ran this on EC2 yet but it seems like our Java extension is missing files. If I go into the extension and run (after installing npm):

npm install
./node_modules/.bin/gulp download_server

Then it activates properly. It remains to be seen whether this is the cause of the Chrome/Safari issues but I'm pretty confused because those files seemed to exist before. We really need to tackle improving our extension marketplace next I think.

@emil-simeonov-se
Copy link
Author

emil-simeonov-se commented Nov 4, 2019

I haven't ran this on EC2 yet but it seems like our Java extension is missing files. If I go into the extension and run (after installing npm):

npm install
./node_modules/.bin/gulp download_server

Then it activates properly. It remains to be seen whether this is the cause of the Chrome/Safari issues but I'm pretty confused because those files seemed to exist before. We really need to tackle improving our extension marketplace next I think.

On my side, going through the steps outlined above helped with getting the Java language support extension activated. However, the reported issue is still there, i.e. I cannot run Java code and code snippets through code-server hosted by a EC2 VM. After 30 min. the VSCode running in a Chrome browser still says "Activating Extensions..."

I opened the Developer tools in Chrome. There are errors and warnings. The warnings are still there with Firefox, there are no errors. I guess these would should be some hints as to what might be wrong.

image

@code-asher
Copy link
Member

On my side, going through the steps outlined above helped with getting the Java language support extension activated. However, the reported issue is still there, i.e. I cannot run Java code and code snippets through code-server hosted by a EC2 VM. After 30 min. the VSCode running in a Chrome browser still says "Activating Extensions..."

I opened the Developer tools in Chrome. There are errors and warnings. The warnings are still there with Firefox, there are no errors. I guess these would should be some hints as to what might be wrong.

Ahh that's interesting! The undefined error there happens on insecure domains but I don't know exactly why yet. The fact that Firefox doesn't have that error but Chrome does seems to be a pretty big clue in the right direction.

It turns out I was able to replicate this locally using just the Dockerfile. On an insecure domain (I'm just using my hosts files to point to localhost since localhost itself is considered secure) Chromium doesn't work but Firefox does, and I see the same difference in errors you described.

I could have sworn I tested an insecure domain last Friday but I'm testing it now and it definitely isn't working so I must have imagined it. It just spins with "activation extensions".

@emil-simeonov-se
Copy link
Author

Now, code-server works great on top of EC2 VMs even without a LB in front. Thank you so much, team! Highly appreciated.

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