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

Need support for a "--headless-hosted-plugin-inspect" backend cmdline argument #13462

Closed
jcortell68 opened this issue Mar 6, 2024 · 3 comments · Fixed by #13918
Closed

Need support for a "--headless-hosted-plugin-inspect" backend cmdline argument #13462

jcortell68 opened this issue Mar 6, 2024 · 3 comments · Fixed by #13918
Assignees
Milestone

Comments

@jcortell68
Copy link
Contributor

jcortell68 commented Mar 6, 2024

Bug Description:

We need support for a --headless-hosted-plugin-inspect (or similar name) backend cmdline argument that will tell the headless plugin-host to listen on that port for a debug attachment. Today, both plugin hosts seem to be affected by the traditional --hosted-plugin-inspect argument, but clearly only one can listen on that port. So the first plugin-host to run gets the port and the other plugin-host becomes un-debuggable. As the headless plugin host always runs first, that's the winner.

Note: the notion of headless plugins was introduced in Theia 1.46.0.

Additional Info
Today I tried debugging a headless plugin using VS Code but in an environment focused on just the plugin developer instead of a Theia app developer that is also developing a plugin. Additionally, the plugin package being developed contributes both a standard plugin (runs in Node.js but interacts with app's frontend) and a headless plugin (runs in Node.js but interacts with app's backend).

Under the covers, there is a plugin-host process for the standard plugins (one for each connected frontend), and a single plugin-host process for all the headless plugins

The way you historically use VSCode to debug a plugin in this plugin-centric type of environment is to launch the app's backend using --hosted-plugin-inspect=<port>, then use a launch config in VS Code like this

{
    "type": "node",
    "request": "attach",
    "name": "Attach to Plugin Host",
    "port": <port>,
    ...
}

But as described earlier, only one of the two plugin-host processes will get to use the port specified via --hosted-plugin-inspect--the first plugin-host to run.

We should have a switch specifically for the headless plugin-host, reserving the current one for the standard plugin host.

Steps to Reproduce:

git clone -b std_and_headless_plugins https://github.com/jcortell68/theiasandbox
cd theiasandbox
yarn
yarn start:electron --hosted-plugin-inspect=9339
  1. In VS Code, launch the Attach to Plugin Host launch configuration.
  2. Set a breakpoint on the "heartbeat" lines of
  • myext\src\extension-headless.ts
  • myext\src\extension.ts
  1. Notice that only the extension-headless.ts breakpoint resolves and is hit

To prove that both plugin-hosts competed for the debug port, remove these lines from package.json

  "theiaPlugin": {
    "headless": "./dist/extension-headless.js"
  },

That will make the plugin-package have just a standard plugin. You'll see that its breakpoint is now hit.

As further proof, the log/console has this:

2024-03-14T13:10:04.417Z root ERROR [hosted-plugin: 15948] Starting inspector on 127.0.0.1:9339 failed: address already in use

Additional Information

  • Operating System: Windows
  • Theia Version: 1.47.1
@jcortell68
Copy link
Contributor Author

@jcortell68
Copy link
Contributor Author

@cdamus FYI

@martin-fleck-at martin-fleck-at self-assigned this Mar 7, 2024
@jfaltermeier jfaltermeier self-assigned this Jul 11, 2024
jfaltermeier added a commit that referenced this issue Jul 11, 2024
* allow to pass down server name to HostedPluginServer from
AbstractHostedPluginSupport
* pass down either hosted-plugin or headless-hosted-plugin
* add preferences to specify node js debug ports per hosted plugin
server
* adjust PluginDebugConfiguration to also accept and array of
server-name to debug port entries
jfaltermeier added a commit that referenced this issue Jul 12, 2024
* refactor to directly set servername on backend instead of handing it
down from frontend
jfaltermeier added a commit that referenced this issue Aug 5, 2024
* address review comments
* remove serverName property
@jfaltermeier jfaltermeier added this to the 1.53.0 milestone Aug 29, 2024
@jcortell68
Copy link
Contributor Author

jcortell68 commented Oct 1, 2024

Update: we moved our product to the latest Theia yesterday. I updated our vscode launch configs to make use of this new argument. Debugging of both standard and headless plugins now works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants