-
Notifications
You must be signed in to change notification settings - Fork 272
Description
Description
When embedding a StackBlitz project from a GitHub repository using the SDK (sdk.connect(iframe)), the embed frequently gets stuck at the "Cloning repo from GitHub" / "Mounting environment in StackBlitz" phase and never progresses. This particularly happens after the repository has been recently updated (e.g., dependency upgrades, new commits).
Steps to Reproduce
- Embed a GitHub project using an iframe URL like:
https://stackblitz.com/github/{org}/{repo}?file=src/example.ts&embed=1&view=editor - Connect via the SDK:
const sdk = await import('@stackblitz/sdk'); const vm = await sdk.connect(iframe);
- Push a change to the GitHub repository (e.g., update dependencies)
- Reload the page containing the embed
Expected Behavior
The embed should clone the latest version of the repository and mount the environment within a reasonable time.
Actual Behavior
The embed gets stuck indefinitely on "Cloning repo from GitHub" with "Mounting environment in StackBlitz" never completing. The WebSocket connection to wss://stackblitz.com/cable fails repeatedly in the console:
WebSocket connection to 'wss://stackblitz.com/cable' failed:
WebSocket connection to 'wss://stackblitz.com/cable' failed:
Additionally, the following console warnings appear (minor, but related):
Unrecognized feature: 'ambient-light-sensor'
Unrecognized feature: 'vr'
Environment
- Browser: Chrome (latest)
- OS: macOS
- SDK:
@stackblitz/sdk(UMD bundle via unpkg) - Embed method: iframe with
sdk.connect()
Workaround
We implemented a client-side workaround that:
- Races
sdk.connect()against a 30-second timeout - After connection, polls
vm.getFsSnapshot()forpackage.jsonto verify the repo actually cloned (sinceconnect()can resolve even when StackBlitz is stuck mounting) - Shows a retry button that remounts the iframe if loading fails
const vm = await Promise.race([
sdk.connect(iframe),
new Promise((_, reject) =>
setTimeout(() => reject(new Error('connect timeout')), 30000)
)
]);
// Verify repo actually cloned
for (let i = 0; i < 15; i++) {
try {
const files = await vm.getFsSnapshot();
if (files && files['package.json']) break;
} catch (_) {}
await new Promise(r => setTimeout(r, 2000));
}Related Issues
- Trying to open GitHub repo in StackBlitz never completes, gets stuck then crashes core#2849 - Stuck on clone
- Preview is stuck on Booting webcontainer for github connected typescript blank project core#2847 - Stuck on boot
- Stuck on dev server when embedded (run), but forking works core#2850 - Stuck on embed
- Hanging on "INITIALIZING GIT REPOSITORY" core#1021 - Hanging on init