firecrawl/open-lovable · error · Error

Failed to install packages: ${response.statusText}

Error message

Failed to install packages: ${response.statusText}

What it means

The client in app/generation/page.tsx POSTs a package list to the install API and, when the fetch response is not ok, throws this Error containing response.statusText. It surfaces HTTP-level failures (4xx/5xx) from the server-side install endpoint, not npm errors themselves.

Source

Thrown at app/generation/page.tsx:438

      textarea.focus();
    }
  };
  
  const installPackages = async (packages: string[]) => {
    if (!sandboxData) {
      addChatMessage('No active sandbox. Create a sandbox first!', 'system');
      return;
    }
    
    try {
      const response = await fetch('/api/install-packages', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ packages })
      });
      
      if (!response.ok) {
        throw new Error(`Failed to install packages: ${response.statusText}`);
      }
      
      const reader = response.body?.getReader();
      const decoder = new TextDecoder();
      
      while (reader) {
        const { done, value } = await reader.read();
        if (done) break;
        
        const chunk = decoder.decode(value);
        const lines = chunk.split('\n');
        
        for (const line of lines) {
          if (line.startsWith('data: ')) {
            try {
              const data = JSON.parse(line.slice(6));
              
              switch (data.type) {

View on GitHub (pinned to 69bd93bae7)

Solutions

  1. Check the server route logs to find the underlying cause behind the statusText
  2. Verify Vercel sandbox credentials (VERCEL_TOKEN, VERCEL_TEAM_ID, VERCEL_PROJECT_ID or OIDC token) in the deployment environment
  3. Recreate/ensure the sandbox before calling the install endpoint, and retry transient 5xx
  4. Validate/sanitize the packages list client-side and surface the HTTP status in the UI

Example fix

// before
if (!response.ok) {
  throw new Error(`Failed to install packages: ${response.statusText}`);
}
// after
if (!response.ok) {
  const body = await response.text().catch(() => '');
  if (response.status >= 500) { await recreateSandbox(); return retryInstall(packages); }
  throw new Error(`Failed to install packages: ${response.status} ${response.statusText} ${body}`);
}
Defensive patterns

Strategy: retry

Validate before calling

const clean = packages.filter(p => typeof p === 'string' && /^[a-z0-9@\-._/]+$/i.test(p));
if (clean.length === 0) throw new Error('No valid packages to install');

Type guard

function isOkResponse(r: Response): r is Response & { ok: true } { return r.ok; }

Try / catch

try {
  const res = await fetch('/api/install', installInit);
  if (!res.ok) throw new InstallHttpError(res.status, res.statusText);
  ...
} catch (e) {
  if (e instanceof InstallHttpError && e.status >= 500) { await sleep(1000); return installPackages(packages, true); }
  addChatMessage(`Install failed: ${e.message}`, 'system');
}

Prevention

When it happens

Trigger: The /api install endpoint returns non-OK: sandbox missing/not provisioned server-side, Vercel credentials invalid, request rate-limited or timed out (504), package name rejected, or the route crashed (500).

Common situations: Sandbox expired server-side between page load and install; deployment missing VERCEL_TOKEN env vars so the API can't reach the sandbox; oversized/invalid package list; Vercel function timeout during a large npm install.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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