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() for package.json to verify the repo actually cloned (since connect() 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
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
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/cablefails repeatedly in the console:Additionally, the following console warnings appear (minor, but related):
Environment
@stackblitz/sdk(UMD bundle via unpkg)sdk.connect()Workaround
We implemented a client-side workaround that:
sdk.connect()against a 30-second timeoutvm.getFsSnapshot()forpackage.jsonto verify the repo actually cloned (sinceconnect()can resolve even when StackBlitz is stuck mounting)Related Issues