salesforce / bazel-vscode-java

Bazel Java development extension for VS Code
BSD 3-Clause "New" or "Revised" License
41 stars 8 forks source link

Make it work with `code serve-web` (or VSC Server over the Web with a Remote Tunnel) [it's OK in GitHub Codespaces] #94

Closed vorburger closed 7 months ago

vorburger commented 7 months ago

I'm exploring using this extension with VSC Server over the Web with a Remote Tunnel.

I initially naively assumed that this would "just work" (for all and any extensions), but am gathering that this may not be so, and extensions such as this one may need to specifically support this way of using VSC?

I have this extension (and this time even remembered to Switch to Pre-Release Version, LOL), but... it seems like it's not even... "active"?!

The usual context menus are missing, and VSC prompts for Maven or Gradle (despite this) - so the extension isn't even "activated" (?), in the web?

https://code.visualstudio.com/api/advanced-topics/remote-extensions#architecture-and-extension-kinds ?

@guw

vorburger commented 7 months ago

Locally starting code serve-web (instead of via https://vscode.dev) seems to reproduce the problem (no menus).

The Extension Runtime Status UI thing does show this though: Activation Event: workspaceContains:**/*.bazelproject,**/WORKSPACE,**/BUILD,**/*.bazel Activation Time:19ms

guw commented 7 months ago

@vorburger We are using the extension without problems in VS Code Server (via browser tabs). I have not tested the SSH/Remote tunnel connection. But I would be surprised if it does not work. We don't do anything special.

vorburger commented 7 months ago

@guw ok, OK; good to know! Then I think this may be a good time to create a simple small self-contained reproducer repo? It could serve to better test this, and perhaps could be useful as a starter/template project to others as well? Let me see if I can cobble something together on https://github.com/vorburger/LearningBazelJavaVSC ... (I'm just fiddling with Dev Containers to see if I can make that demo project "just work out of the box" easily.)

vorburger commented 7 months ago

Indeed https://github.com/vorburger/LearningBazelJavaVSC works nicely e.g. in a GitHub Codespace! Cool.

There, I've used https://github.com/devcontainers-community/features-bazel to make bazelisk available, that works great.

But (first systemctl --user stop code-tunnel.service, to avoid any confusion, and then) starting code serve-web locally with /home/vorburger/git/github.com/vorburger/LearningBazelJavaVSC as my current working directory (which doesn't seem to matter), and then opening that same path as Folder (so same project) seem to reproduce a similar problem - missing menus, and (now) both this as well as the Language Support for Java(TM) by Red Hat extensions having Runtime Status show Not yet activated. - at least that makes more sense.

So it's like the Extension doesn't "kick in" to "configure the project" at all - even after opening the first *.java (I figured it's normal before that). I've no idea what can causing this. How to even start to further debug this?

vorburger commented 7 months ago

At some point during my tests there was very high CPU usage (code ran rg like forever at 100% CPU).

Perhaps it "missed" the extensions' initialization and "timed out" - is that possible?

I've noticed that when this extension is Not yet activated. and I invoke e.g. its Show Bazel Build Status command,

then "Activating Extensions" shows up in the status bar for like 7s, and then goes away - it probably fails to start?

Which log/s are relevant to that? I've stumbled upon a Developer: Show Logs... with Extension Host (Remote) with:

2024-02-10 16:36:29.155 [info] ExtensionService#_doActivateExtension BazelBuild.vscode-bazel, startup: false, activationEvent: 'onLanguage:starlark'
2024-02-10 16:36:34.054 [info] ExtensionService#_doActivateExtension redhat.vscode-yaml, startup: false, activationEvent: 'onLanguage:yaml'
2024-02-10 16:37:25.279 [info] ExtensionService#_doActivateExtension josevseb.google-java-format-for-vs-code, startup: false, activationEvent: 'onLanguage:java'
2024-02-10 16:37:25.279 [info] ExtensionService#_doActivateExtension seaube.clangformat, startup: false, activationEvent: 'onLanguage:java'
2024-02-10 16:37:25.280 [info] ExtensionService#_doActivateExtension VisualStudioExptTeam.vscodeintellicode, startup: false, activationEvent: 'onLanguage:java'
2024-02-10 16:37:25.280 [info] ExtensionService#_doActivateExtension vscjava.vscode-java-debug, startup: false, activationEvent: 'onLanguage:java'
2024-02-10 16:37:25.280 [info] ExtensionService#_doActivateExtension vscjava.vscode-java-dependency, startup: false, activationEvent: 'onLanguage:java'
2024-02-10 16:37:25.280 [info] ExtensionService#_doActivateExtension vscjava.vscode-java-pack, startup: false, activationEvent: 'onLanguage:java'

but I'm sure how relevant that is, as even in "normal" (old style) VSC client my exthost.log has startup: false.

vorburger commented 7 months ago

At some point during my tests there was very high CPU usage (code ran rg like forever at 100% CPU).

Wait a second... I may have a hardware issue?! CPU is often (very, 0.40 GHz ?) throttled - I better sort that out, first...

Let me close this, for now; I may re-open, later.

guw commented 7 months ago

@vorburger There was problem in the extension that I discovered today. A fix was pushed around noon CET.

vorburger commented 7 months ago

@vorburger There was problem in the extension that I discovered today. A fix was pushed around noon CET.

I'm on v1.24.102131300 - should that have the fix you're referring to?

I've re-opened this, because I'm now on an entirely different machine, without CPU throttling issues - and still NOK:

Indeed https://github.com/vorburger/LearningBazelJavaVSC works nicely e.g. in a GitHub Codespace! Cool.

To reproduce, and focus the issue, let's forget about GitHub Codespaces and Dev Containers and what not, and zoom in (here) only on "using this extension with VSC Server over the Web with a Remote Tunnel."

So I have https://github.com/vorburger/LearningBazelJavaVSC working in a "local" (non-Web) VSC. I then installed the VSC Server as a systemd user service. (I believe one can also start the tunnel service from the local VSC client, although I don't do it like that.)

When I now access the same project (on the same path, on the same machine) via https://vscode.dev/tunnel/YOUR-TUNNEL/home/vorburger/git/github.com/vorburger/LearningBazelJavaVSC, it has the problem I described above - Runtime Status: Not yet activated.

@guw this should hopefully be reproducible for you? If it works for you, then I'm really puzzled... 🤣

How to we best further debug this?

guw commented 7 months ago

Might be silly question ... does it work for a pure Maven or Gradle project? I don't have cycle to investigate.

vorburger commented 7 months ago

Might be silly question ... does it work for a pure Maven or Gradle project? I don't have cycle to investigate.

Not silly at all - great idea to check that out first, so I've just tested it - and yup, that seems to work...

(For my future records: What I've tested specifically is https://github.com/google/google-java-format on https://vscode.dev/tunnel/YOUR-TUNNEL/home/vorburger/git/github.com/google/google-java-format, and that initializes both Maven AND Gradle, because that repo happens to have both pom.xml and a idea_plugin/build.gradle.kts, and it seems to work just fine.)

vorburger commented 7 months ago

Note to my future self, or others further investigating this in the future:

ONCE the more basic fundamental problem of the extension not even activating in VSC Web is resolved,

THEN this is may also become related to #103... remember, the VSC tunnel server systemd unit may well not see the bazel on PATH - depending on exactly / how where it's installed. (E.g. the way I personally set this up, it's activated in my user profile, which may not get run by the systemd user unit? TBC. Better logging from the extension when it runs Bazel will here, too. But this will only be relevant once the extension actually activates on the web.)

vorburger commented 7 months ago

@guw I've investigated this further. Here is my current understanding:

  1. This extension WORKS in GitHub Codespaces - but (only) IFF one uses this sort of trickery to make it find bazel!
  2. This extension doesn't seem to work yet with code serve-web; it simply does not activate. This is also the easiest way to reproduce it (example) - much easier than bothering with tunnels (and their auth problems)
  3. This extension doesn't seem to work yet with Tunnels; but that's likely same root cause as above.
guw commented 7 months ago

@vorburger Something else must be broken then. code serve-web works. I just re-tried it myself on my iMac. I can open the browser to localhost and install the extension and other Java extensions without problems. Note, at first the Java language server opens in "Lightweight" mode. You have to actively switch it to "Standard" mode. This can also be done via .vscode/settings.json.

    "java.server.launchMode": "Standard",