garrytan/gstack · error · Error

Download failed: ${failure}

Error message

Download failed: ${failure}

What it means

Error "Download failed: ${failure}" thrown in garrytan/gstack.

Source

Thrown at browse/src/write-commands.ts:1226

        contentType = match[1];
        buffer = Buffer.from(match[2], 'base64');
      } else if (useNavigate) {
        // Strategy 2: Navigate to URL and capture browser-triggered download.
        // Handles URLs that trigger file downloads via redirects,
        // Content-Disposition headers, or anti-bot CDN chains where
        // page.request.fetch() can't follow the auth/redirect chain.
        await validateNavigationUrl(url);
        const downloadPromise = page.waitForEvent('download', { timeout: 60000 });
        // Use goto with 'commit' wait — the page may redirect to trigger
        // the download, so 'domcontentloaded' may never fire.
        page.goto(url, { waitUntil: 'commit', timeout: 30000 }).catch(() => {
          // Navigation may "fail" because the response is a download,
          // not a page. The download event handles it.
        });
        const download = await downloadPromise;
        const failure = await download.failure();
        if (failure) {
          throw new Error(`Download failed: ${failure}`);
        }
        // Save to temp location first, then read into buffer
        const tempPath = path.join(TEMP_DIR, `browse-nav-download-${Date.now()}`);
        await download.saveAs(tempPath);
        buffer = fs.readFileSync(tempPath);
        // Try to infer content type from suggested filename
        const suggested = download.suggestedFilename();
        if (suggested) {
          const extMatch = suggested.match(/\.([a-z0-9]+)$/i);
          if (extMatch) {
            const extLower = extMatch[1].toLowerCase();
            const mimeMap: Record<string, string> = {
              epub: 'application/epub+zip', pdf: 'application/pdf',
              zip: 'application/zip', gz: 'application/gzip',
              mp3: 'audio/mpeg', mp4: 'video/mp4',
              jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png',
              txt: 'text/plain', html: 'text/html', json: 'application/json',
            };

View on GitHub (pinned to 94993f7401)

When it happens

Trigger: Thrown at browse/src/write-commands.ts:1226 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12). Data as JSON: /api/errors/2db4dccce5596eaa. Report an issue: GitHub.