feat: API to ping Web IDE workbench host from GitLab instance
Issue: [Web IDE] Use .cdn.web-ide.gitlab-static.net to... (gitlab#537406 - closed)
What does this MR do and why?
It implements a pingWebIDEWorkbench API that checks if the Web IDE VSCode Workbench assets host (cdn.web-ide.gitlab-static.net) is reachable from a GitLab instance.
How does this API work?
The Web IDE VSCode Workbench loader emits a web-ide-config-request event when it starts using the iframe's postMessage API. The pingWebIDEWorkbench method temporarily inserts an iframe in the document and waits for the web-ide-config-request for 2.5 seconds. It removes the iframe when the message is received or the wait mechanism times out.
What are the other changes included in this MR?
Code splitting to reduce assets loading time
I want Web IDE VSCode Workbench loader assets to start faster To achieve this goal, I enabled code splitting in the ESBuild configuration and changed the loader implementation to dynamically load the VSCode assets only if the initial configuration sent by the GitLab instance is received. This change reduced the size of the loader from +700kb to ~7kb (2kb gzipped). As a result, the ping operation should be significantly faster.
Disable extension marketplace if cross origin extension host is not available
If the cdn.web-ide.gitlab-static.net assets host is not reachable and, as a result, the multi-domain extension host is disabled, we also disable the Extension Marketplace to limit the potential surface attack by disabling 3rd-party extensions.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
This MR doesn't introduce visual changes.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Follow the introductions to test and validate these changes in the Merge Request that uses the pingWebIDEWorkbench API in the GitLab instance gitlab!193417 (merged).