jackwener/OpenCLI · error · CommandExecutionError

Failed to fetch Flomo memos: ${err instanceof Error ? err.me

Error message

Failed to fetch Flomo memos: ${err instanceof Error ? err.message : String(err)}

What it means

fetchFlomoJson wraps the low-level fetch to https://flomoapp.com/api/v1/memo/updated/. If fetch itself rejects — DNS failure, connection refused/reset, TLS error, timeout, or offline — this CommandExecutionError is thrown with the underlying error message embedded. It means the request never got an HTTP response, so it is a network-layer problem, not an API error.

Source

Thrown at clis/flomo/memos.js:156

    tags: normalizeTags(memo.tags),
    images: normalizeImages(memo.files),
    created_at: String(memo.created_at || ''),
    updated_at: String(memo.updated_at || ''),
  };
}

async function fetchFlomoJson(url, token) {
  let resp;
  try {
    resp = await fetch(url, {
      headers: {
        Authorization: 'Bearer ' + token,
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
        Accept: 'application/json',
      },
    });
  } catch (err) {
    throw new CommandExecutionError(`Failed to fetch Flomo memos: ${err instanceof Error ? err.message : String(err)}`);
  }
  if (resp.status === 401 || resp.status === 403) {
    throw new AuthRequiredError(FLOMO_API_DOMAIN, `Flomo API returned HTTP ${resp.status}; please refresh your Flomo login session`);
  }
  if (!resp.ok) {
    throw new CommandExecutionError(`Flomo API returned HTTP ${resp.status}`);
  }
  try {
    return await resp.json();
  } catch (err) {
    throw new CommandExecutionError(`Flomo API returned malformed JSON: ${err instanceof Error ? err.message : String(err)}`);
  }
}

async function readAccessToken(page) {
  const token = unwrapBrowserResult(await page.evaluate(buildGetTokenJs()));
  if (typeof token !== 'string' || !token.trim()) {
    throw new AuthRequiredError(FLOMO_API_DOMAIN, 'Flomo memos requires an active signed-in Flomo browser session');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check basic connectivity (e.g. curl https://flomoapp.com) and retry the command.
  2. Disable or reconfigure VPN/proxy that may block or intercept flomoapp.com traffic.
  3. Verify DNS resolves flomoapp.com (try a public resolver like 1.1.1.1).
  4. Increase any network timeouts or retry with exponential backoff for transient failures.

Example fix

// before: single call, fails hard on transient network error
const body = await fetchFlomoJson(url, token);
// after: retry transient network failures
let body;
for (let i = 0; i < 3; i++) {
  try { body = await fetchFlomoJson(url, token); break; }
  catch (e) {
    if (i === 2 || /HTTP \d+/.test(e.message)) throw e; // non-network errors don't retry
    await new Promise((r) => setTimeout(r, 2 ** i * 500));
  }
}
Defensive patterns

Strategy: retry

Validate before calling

// before calling the CLI, verify reachability of the API host
const ok = await fetch('https://flomoapp.com', { method: 'HEAD' })
  .then(() => true)
  .catch(() => false);
if (!ok) throw new Error('flomoapp.com is unreachable; check network/VPN/DNS before running flomo memos');

Type guard

null

Try / catch

try {
  body = await fetchFlomoJson(url, token);
} catch (err) {
  if (err.message.startsWith('Failed to fetch Flomo memos')) {
    // network-layer failure: retry with backoff
    for (let i = 1; i <= 3; i++) {
      await new Promise((r) => setTimeout(r, i * 1000));
      try { body = await fetchFlomoJson(url, token); break; } catch {}
    }
  }
  if (!body) throw err;
}

Prevention

When it happens

Trigger: Calling `flomo memos` while offline; DNS resolution failure for flomoapp.com; TLS interception by a corporate proxy; connection reset/timeout; IPv6 connectivity issues; firewall blocking the outbound request from the headless browser host.

Common situations: Working on a VPN or corporate network that blocks or MITMs flomoapp.com; laptop asleep/network flapping during the CLI run; DNS misconfiguration; the browser session host having no internet access.

Related errors


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