jackwener/OpenCLI · error · CommandExecutionError

Failed to read Upwork feed state: ${e?.message ?? e}

Error message

Failed to read Upwork feed state: ${e?.message ?? e}

What it means

The `upwork feed` command evaluates an in-page script that reads window.__NUXT__.state.<feedKey>. If that page.evaluate call itself throws (syntax/runtime error, bridge serialization failure, page navigated mid-evaluation, execution context destroyed), the CLI wraps the underlying error in this CommandExecutionError with a hint to open Upwork in the connected browser. It signals the Nuxt state global was not reachable, distinct from the state simply not being ready.

Source

Thrown at clis/upwork/feed.js:79

                    if (ready) break;
                    await new Promise(r => setTimeout(r, 500));
                    ready = haveState();
                }
                const onLogin = /\\/(ab\\/account-security\\/login|nx\\/login)/.test(location.pathname);
                const challenge = (document.title || '').toLowerCase().includes('just a moment') || !!document.querySelector('[id^="cf-"]');
                const state = window.__NUXT__ && window.__NUXT__.state && window.__NUXT__.state[key];
                return {
                    ready,
                    onLogin,
                    challenge,
                    jobsPresent: !!(state && Object.prototype.hasOwnProperty.call(state, 'jobs')),
                    jobs: state ? state.jobs : undefined,
                    paging: state && state.paging ? state.paging : null,
                };
            })()`));
        }
        catch (e) {
            throw new CommandExecutionError(`Failed to read Upwork feed state: ${e?.message ?? e}`, 'The Nuxt state global was not reachable; try again after opening Upwork in the connected browser.');
        }

        if (payload?.onLogin) {
            throw new AuthRequiredError('upwork.com', 'Upwork redirected to login. Open https://www.upwork.com in the connected browser and sign in, then retry.');
        }
        if (payload?.challenge) {
            throw new CommandExecutionError('Upwork served a Cloudflare challenge page', 'Open https://www.upwork.com in the connected browser and clear the challenge, then retry.');
        }
        if (!payload?.ready) {
            throw new CommandExecutionError(`Upwork feed state (window.__NUXT__.state.${stateKey}) was not present within 15s`, 'The page may not have finished hydrating, or the SSR state shape may have changed.');
        }
        if (!isPlainObject(payload)) {
            throw new CommandExecutionError('Upwork feed returned an unexpected Browser Bridge payload shape');
        }
        if (!payload.jobsPresent || !Array.isArray(payload.jobs)) {
            throw new CommandExecutionError(`Upwork feed state had an unexpected jobs shape; expected window.__NUXT__.state.${stateKey}.jobs to be an array.`);
        }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open https://www.upwork.com in the connected browser, confirm the site loads normally and you are signed in, then retry the command.
  2. Re-run the command — a transient navigation/reload race often resolves on a second attempt.
  3. Disable content-blocking extensions for upwork.com or use a clean browser profile.
  4. Check Upwork status / try another page; if the app shell is down, wait and retry later.

Example fix

// before
await upwork.feed();  // fails while a redirect destroys the eval context
// after
await upwork.feed();  // retry after confirming upwork.com is open and signed in
// or wrap with backoff
for (let i = 0; i < 3; i++) { try { return await upwork.feed(); } catch (e) { if (!/Failed to read Upwork feed state/.test(e.message)) throw e; await sleep(2000); } }
Defensive patterns

Strategy: retry

Validate before calling

// before batch runs, confirm the browser session is usable
const ok = await bridge.probe('https://www.upwork.com'); // page loads and you are signed in

Try / catch

try {
  const jobs = await upwork.feed();
} catch (e) {
  if (/Failed to read Upwork feed state/.test(e.message) && attempt < 3) {
    await sleep(2000 * attempt);
    return feedWithRetry(attempt + 1);
  }
  throw e;
}

Prevention

When it happens

Trigger: page.evaluate on www.upwork.com throws: the execution context is destroyed by a redirect/reload during the 15s poll, the browser bridge fails to serialize the result, a JS error occurs inside the IIFE, or window.__NUXT__ is protected/unavailable (extension interference, hardened privacy setup).

Common situations: Upwork redirects mid-load (login or onboarding flow) destroying the evaluation context; a browser extension (ad blocker, privacy tool) blocking Nuxt globals; the connected browser closed or navigated away by the user mid-run; an Upwork outage returning an error page with no app shell.

Related errors


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