jackwener/OpenCLI · error · CommandExecutionError

LinkedIn did not issue a messaging API request; the inbox ma

Error message

LinkedIn did not issue a messaging API request; the inbox may have failed to load.

What it means

The CLI waits for the messaging page to fire its internal messaging API request and captures the URL. If after the initial check and one retry (extra 6-unit wait) no API request URL can be located, it concludes the inbox SPA failed to load and throws a CommandExecutionError. This is a page-load/network-level failure, not an auth failure.

Source

Thrown at clis/linkedin/inbox.js:180

      }
    }
    const unreadOnly = Boolean(kwargs['unread-only']);

    await page.goto(MESSAGING_URL);
    await page.wait(10);

    // Locate the messaging API request the page fired on load; retry once if the
    // SPA was slow to issue it.
    let located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));
    if (located && located.loginRequired) {
      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn requires an active signed-in browser session.');
    }
    if (!located || !located.url) {
      await page.wait(6);
      located = unwrapEvaluateResult(await page.evaluate(`(${findMessagingApiUrl.toString()})()`));
    }
    if (!located || !located.url) {
      throw new CommandExecutionError(
        'LinkedIn did not issue a messaging API request; the inbox may have failed to load.',
      );
    }

    const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });
    const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;
    if (!jsession) {
      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn.');
    }
    const csrf = jsession.replace(/^"|"$/g, '');

    // Widen the page size to the requested limit where the query supports it.
    const targetUrl = located.url.replace(/count:\d+/, 'count:' + limit);
    const fetched = unwrapEvaluateResult(
      await page.evaluate(`(${fetchMessagingApi.toString()})(${JSON.stringify(targetUrl)}, ${JSON.stringify(csrf)})`),
    );
    if (fetched && fetched.authRequired) {
      throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn messaging API authentication failed: ' + fetched.error);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command; transient SPA slowness or a slow network is the most common cause.
  2. Disable ad-blockers/proxy interference for linkedin.com in the automated browser profile.
  3. Check linkedin.com messaging loads manually in the same profile; if LinkedIn itself errors, wait and retry.
  4. If it persists after LinkedIn works manually, the detection script may need updating for a LinkedIn layout/API change — report/update the library.

Example fix

// before
await cli.inbox(); // CommandExecutionError on flaky network

// after
await retry(() => cli.inbox(), { attempts: 3, backoff: 'exponential' });
Defensive patterns

Strategy: retry

Validate before calling

async function messagingReachable() {
  try { const r = await fetch('https://www.linkedin.com/messaging/'); return r.ok || r.status < 500; }
  catch { return false; }
}

Type guard

const isApiRequestMissing = (e) => e instanceof CommandExecutionError && /did not issue .* API request/i.test(e?.message || '');

Try / catch

try {
  return await linkedinInbox();
} catch (e) {
  if (isApiRequestMissing(e)) {
    await sleep(5000);
    return retry(linkedinInbox, { attempts: 3, backoff: (n) => 2 ** n * 1000 });
  }
  throw e;
}

Prevention

When it happens

Trigger: findMessagingApiUrl() returns nothing usable on both attempts: LinkedIn served an error page, the SPA JS crashed or was slow, network blocked voyager/messaging endpoints, or an A/B layout changed the request pattern.

Common situations: Slow corporate proxy or ad-blocker stripping API calls, LinkedIn outage or 5xx page, very slow machine where even the retry wait is insufficient, or LinkedIn DOM/network changes breaking the detection script.

Related errors


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