Skip to content

Embedded GitHub project gets stuck on "Cloning repo from GitHub" / "Mounting environment" after recent repo changes #2075

@veigap

Description

@veigap

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

  1. Embed a GitHub project using an iframe URL like:
    https://stackblitz.com/github/{org}/{repo}?file=src/example.ts&embed=1&view=editor
    
  2. Connect via the SDK:
    const sdk = await import('@stackblitz/sdk');
    const vm = await sdk.connect(iframe);
  3. Push a change to the GitHub repository (e.g., update dependencies)
  4. 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:

  1. Races sdk.connect() against a 30-second timeout
  2. After connection, polls vm.getFsSnapshot() for package.json to verify the repo actually cloned (since connect() can resolve even when StackBlitz is stuck mounting)
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions