jackwener/OpenCLI · error · CommandExecutionError

linux.do returned an empty browser response

Error message

linux.do returned an empty browser response

What it means

fetchTopicPayload runs in-browser fetch code and expects a JSON result object. If the browser evaluation returns nothing (null/undefined), the library cannot proceed and throws a CommandExecutionError indicating the browser response was empty.

Source

Thrown at clis/linux-do/topic-content.js:107

        data = await res.json();
      } catch (_error) {
        data = null;
      }
      return {
        ok: res.ok,
        status: res.status,
        data,
        error: data === null ? 'Response is not valid JSON' : '',
      };
    } catch (error) {
      return {
        ok: false,
        error: error instanceof Error ? error.message : String(error),
      };
    }
  })()`);
    if (!result) {
        throw new CommandExecutionError('linux.do returned an empty browser response');
    }
    if (result.status === 401 || result.status === 403) {
        throw new AuthRequiredError(LINUX_DO_DOMAIN, 'linux.do requires an active signed-in browser session');
    }
    if (result.error === 'Response is not valid JSON') {
        throw new AuthRequiredError(LINUX_DO_DOMAIN, 'linux.do requires an active signed-in browser session');
    }
    if (!result.ok) {
        throw new CommandExecutionError(result.error || `linux.do request failed: HTTP ${result.status ?? 'unknown'}`);
    }
    if (result.error) {
        throw new CommandExecutionError(result.error, 'Please verify your linux.do session is still valid');
    }
    return result.data;
}
cli({
    site: 'linux-do',
    name: 'topic-content',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command; transient navigation interruptions often disappear on retry.
  2. Ensure the browser page stays open and on a linux.do domain during the fetch.
  3. Confirm network connectivity and that linux.do is reachable.
  4. Check the CLI's browser automation setup (Playwright/CDP) for navigation guards or timeouts.

Example fix

// before
const result = await page.evaluate(fetchScript);
const content = extractTopicContent(result.data, id);
// after
const result = await page.evaluate(fetchScript);
if (!result || !result.data) {
  throw new Error('Empty browser response — keep the linux.do tab open and retry');
}
const content = extractTopicContent(result.data, id);
Defensive patterns

Strategy: retry

Validate before calling

if (!page || page.isClosed?.()) {
  throw new Error('Browser page unavailable before topic fetch');
}

Type guard

const isBrowserResult = (r) => r !== null && r !== undefined && typeof r === 'object' && 'status' in r;

Try / catch

try {
  return await fetchTopicPayload(page, id);
} catch (e) {
  if (e instanceof CommandExecutionError && /empty browser response/.test(e.message)) {
    await page.goto(LINUX_DO_URL).catch(() => {});
    return fetchTopicPayload(page, id); // one retry
  } else throw e;
}

Prevention

When it happens

Trigger: The injected page.evaluate script returns undefined/null — e.g. navigation cancelled, page closed mid-fetch, the async IIFE throwing before returning an object and the harness swallowing it, or the tab being redirected away from linux.do.

Common situations: User closes the browser/tab during fetch; a popup or login redirect aborts the evaluate; headless browser crash; network offline causing the fetch to be aborted without a status.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/d88e9fa947697134. Report an issue: GitHub.