eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.29k stars 2.45k forks source link

Correctly load frontend plugins when deployed under a path #13813

Closed sgraband closed 1 day ago

sgraband commented 2 weeks ago

Bug Description:

Currently in worker-main importScripts is used to load the plugin-vscode-init-fe.ts. However, this does not work for instances, where Theia is not hosted at the base-url (or origin), like the try.theia-cloud.io deployment, where each instance of Theia is hosted under ws.theia-cloud.io/<pod-id>.

After a quick investigation the problem seems to be that importScripts is called with /context/<file-name>, which is a absolute path. Hence it resolves to only base-url/context/<file-name>, whereas we would need base-url/<pod-id>/context/<file-name>. This could be fixed by simply calling importScripts with ./context/<file-name>. I already tested this and it seems to work.

Does anyone have any concerns about that change? It should not change the behavior for other use cases, but fix the issue for that specifc scenario.

I can gladly contribute this.

Steps to Reproduce:

  1. Use a hosted Theia instance that is running under a path (e.g. https://try.theia-cloud.io/ - path meaning, that the pods are running under ws.theia-cloud.io/<pod-id> and not just ws.theia-cloud.io)
  2. Install a frontend-only vscode extension
  3. Observe that the console throws and error that the plugin-vscode-init-fe.js fails to load.

Additional Information

msujew commented 2 weeks ago

@sgraband We had a similar issue related to loading resources from notebook output webviews. See https://github.com/eclipse-theia/theia/pull/12976. A fix would likely be similar.