firecrawl/open-lovable · error · Error

Unknown error

Error message

Unknown error

What it means

createSandbox() in app/generation/page.tsx throws this Error when the sandbox-creation API responds with ok:false and no `error` field, falling back to 'Unknown error'. It is the client-side catch-all for failed sandbox provisioning whose server response lacks a message.

Source

Thrown at app/generation/page.tsx:605

        console.log('[createSandbox] Sandbox ready with Vite server running');
        
        // Only add welcome message if not coming from home screen
        if (!fromHomeScreen) {
          addChatMessage(`Sandbox created! ID: ${data.sandboxId}. I now have context of your sandbox and can help you build your app. Just ask me to create components and I'll automatically apply them!

Tip: I automatically detect and install npm packages from your code imports (like react-router-dom, axios, etc.)`, 'system');
        }
        
        setTimeout(() => {
          if (iframeRef.current) {
            iframeRef.current.src = data.url;
          }
        }, 100);
        
        // Return the sandbox data so it can be used immediately
        return data;
      } else {
        throw new Error(data.error || 'Unknown error');
      }
    } catch (error: any) {
      console.error('[createSandbox] Error:', error);
      updateStatus('Error', false);
      log(`Failed to create sandbox: ${error.message}`, 'error');
      addChatMessage(`Failed to create sandbox: ${error.message}`, 'system');
      throw error;
    } finally {
      setLoading(false);
      sandboxCreationRef.current = false; // Reset the ref
    }
  };

  const displayStructure = (structure: any) => {
    if (typeof structure === 'object') {
      setStructureContent(JSON.stringify(structure, null, 2));
    } else {
      setStructureContent(structure || 'No structure available');

View on GitHub (pinned to 69bd93bae7)

Solutions

  1. Log the full response (status + body) in the API route to expose the real failure
  2. Ensure the server route always includes an `error` message in failure payloads
  3. Check that Vercel/E2B credentials and upstream sandbox APIs are reachable/valid
  4. Retry creation on transient failures and surface the true status code in the chat error message

Example fix

// before
throw new Error(data.error || 'Unknown error');
// after
const detail = data.error || `status ${response.status}: ${await response.text().catch(() => 'no body')}`;
throw new Error(detail);
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch('/api/sandbox', { method: 'POST' });
const payload = await res.json();
if (!res.ok || !payload?.ok) throw new Error(`Sandbox API failed: ${res.status} ${payload?.error ?? 'no detail'}`);

Type guard

function isSandboxData(v: unknown): v is { sandboxId: string; url: string } { return !!v && typeof v === 'object' && typeof (v as any).sandboxId === 'string'; }

Try / catch

try {
  const data = await createSandbox();
} catch (error) {
  updateStatus('Error', false);
  log(`Failed to create sandbox: ${error.message}`, 'error');
  addChatMessage(`Failed to create sandbox: ${error.message}`, 'system');
  throw error;
}

Prevention

When it happens

Trigger: POST to the sandbox API returns ok:false with an absent/empty error string — server crashed before setting error, proxy/gateway returned an unexpected payload, auth rejected the request with a bare body, or JSON shape changed between client and API.

Common situations: Vercel function returning 500 without a JSON body; expired auth token; provider (E2B/Vercel) API outage server-side; API route updated its response contract while the page expects data.error.

Related errors


AI-assisted analysis of firecrawl/open-lovable@69bd93bae7 (2026-08-28). Data as JSON: /api/errors/a927a38258201d17. Report an issue: GitHub.