jackwener/OpenCLI · error · CommandExecutionError

Jianyu whoami failed

Error message

Jianyu whoami failed: ${probe.detail}

What it means

CommandExecutionError thrown by verifyJianyuIdentity when the in-page probe function itself threw an exception (the probe catches its own errors and returns { kind: 'exception', detail }). This means the identity check could not even complete — the probe wraps the fetch to the sess endpoint and JSON parsing of window.__USER__ in try/catch, and any failure (network error inside page, fetch rejection, CSP block) surfaces here.

Solutions

  1. Read probe.detail in the message to identify the underlying exception and fix that cause (DNS, proxy, 5xx)
  2. Retry after confirming https://www.jianyu360.cn/ loads in the automated browser
  3. Disable or relax proxy/VPN/ad-blockers that may block the in-page fetch
  4. Verify the sess endpoint still exists; if the site changed it, update the fetch URL in verifyJianyuIdentity
  5. Wrap verification in retry with backoff for transient network errors

Example fix

// before
const probe = await page.evaluate(...); // detail: 'Failed to fetch'
// after (retry transient failures)
for (let i = 0; i < 3; i++) {
  try { return await verifyJianyuIdentity(page); }
  catch (e) { if (!/Failed to fetch/.test(e.message) || i === 2) throw e; await page.wait(2); }
}
Defensive patterns

Strategy: retry

Validate before calling

await page.goto('https://www.jianyu360.cn/');
await page.wait(2); // ensure page is stable and on-domain before probing
if (!page.url().includes('jianyu360.cn')) throw new Error('Page navigated away; probe would fail');

Type guard

function isProbeException(probe) {
  return probe != null && typeof probe === 'object' && probe.kind === 'exception' && typeof probe.detail === 'string';
}

Try / catch

try {
  const identity = await verifyJianyuIdentity(page);
} catch (e) {
  if (/Jianyu whoami failed: (Failed to fetch|NetworkError)/.test(e.message)) {
    await page.wait(3); // retry transient network failures
    return verifyJianyuIdentity(page);
  }
  throw e;
}

Prevention

When it happens

Trigger: The page.evaluate probe's internal fetch to /swordfish/frontPage/customer/sess/index with credentials: 'include' rejects (network failure, redirect, CORS/CSP), or another runtime error occurs inside the probe's try block; detail contains the exception message.

Common situations: Jianyu site temporarily down or returning 5xx; proxy/VPN blocking the in-page request; browser page navigated away mid-probe; site removed or moved the sess endpoint; page context destroyed by a redirect during page.goto.

Related errors


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

Appendix: source

Thrown at clis/jianyu/auth.js:44

      if (userScript) {
        try {
          const u = JSON.parse(userScript);
          userId = userId || String(u.id || u.userId || '');
          name = String(u.name || u.realName || u.nickName || '');
        } catch {}
      }
      const cookieUid = (document.cookie.split('; ').find(c => c.startsWith('userid_secure=')) || '').split('=')[1] || '';
      userId = userId || cookieUid;
      if (!userId && !name) {
        return { kind: 'auth', detail: 'Jianyu protected page 200 but no user identity surface' };
      }
      return { ok: true, user_id: userId, name };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (probe?.kind === 'auth') throw new AuthRequiredError('jianyu360.cn', probe.detail);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`Jianyu whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jianyu probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, name: probe.name };
}

registerSiteAuthCommands({
  site: 'jianyu',
  domain: 'jianyu360.cn',
  loginUrl: 'https://www.jianyu360.cn/',
  columns: ['user_id', 'name'],
  quickCheck: hasJianyuUserCookie,
  verify: verifyJianyuIdentity,
  poll: async (page) => {
    if (!await hasJianyuUserCookie(page)) {
      throw new AuthRequiredError('jianyu360.cn', 'Waiting for Jianyu userid_secure cookie');
    }
    return verifyJianyuIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)