{"record":{"id":"3ae76c4ecc21ecea","repo":"jackwener/OpenCLI","slug":"failed-to-read-upwork-feed-state-e-message","errorCode":null,"errorMessage":"Failed to read Upwork feed state: ${e?.message ?? e}","messagePattern":"Failed to read Upwork feed state: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/upwork/feed.js","lineNumber":79,"sourceCode":"                    if (ready) break;\n                    await new Promise(r => setTimeout(r, 500));\n                    ready = haveState();\n                }\n                const onLogin = /\\\\/(ab\\\\/account-security\\\\/login|nx\\\\/login)/.test(location.pathname);\n                const challenge = (document.title || '').toLowerCase().includes('just a moment') || !!document.querySelector('[id^=\"cf-\"]');\n                const state = window.__NUXT__ && window.__NUXT__.state && window.__NUXT__.state[key];\n                return {\n                    ready,\n                    onLogin,\n                    challenge,\n                    jobsPresent: !!(state && Object.prototype.hasOwnProperty.call(state, 'jobs')),\n                    jobs: state ? state.jobs : undefined,\n                    paging: state && state.paging ? state.paging : null,\n                };\n            })()`));\n        }\n        catch (e) {\n            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.');\n        }\n\n        if (payload?.onLogin) {\n            throw new AuthRequiredError('upwork.com', 'Upwork redirected to login. Open https://www.upwork.com in the connected browser and sign in, then retry.');\n        }\n        if (payload?.challenge) {\n            throw new CommandExecutionError('Upwork served a Cloudflare challenge page', 'Open https://www.upwork.com in the connected browser and clear the challenge, then retry.');\n        }\n        if (!payload?.ready) {\n            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.');\n        }\n        if (!isPlainObject(payload)) {\n            throw new CommandExecutionError('Upwork feed returned an unexpected Browser Bridge payload shape');\n        }\n        if (!payload.jobsPresent || !Array.isArray(payload.jobs)) {\n            throw new CommandExecutionError(`Upwork feed state had an unexpected jobs shape; expected window.__NUXT__.state.${stateKey}.jobs to be an array.`);\n        }\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/upwork/feed.js#L61-L97","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Open https://www.upwork.com in the connected browser, confirm the site loads normally and you are signed in, then retry the command.","Re-run the command — a transient navigation/reload race often resolves on a second attempt.","Disable content-blocking extensions for upwork.com or use a clean browser profile.","Check Upwork status / try another page; if the app shell is down, wait and retry later."],"exampleFix":"// before\nawait upwork.feed();  // fails while a redirect destroys the eval context\n// after\nawait upwork.feed();  // retry after confirming upwork.com is open and signed in\n// or wrap with backoff\nfor (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); } }","handlingStrategy":"retry","validationCode":"// before batch runs, confirm the browser session is usable\nconst ok = await bridge.probe('https://www.upwork.com'); // page loads and you are signed in","typeGuard":null,"tryCatchPattern":"try {\n  const jobs = await upwork.feed();\n} catch (e) {\n  if (/Failed to read Upwork feed state/.test(e.message) && attempt < 3) {\n    await sleep(2000 * attempt);\n    return feedWithRetry(attempt + 1);\n  }\n  throw e;\n}","preventionTips":["Keep the Upwork tab open and stationary in the connected browser during runs.","Disable aggressive ad/privacy extensions for upwork.com.","Add backoff between scripted calls so redirects/outages don't compound.","Pre-open upwork.com and verify sign-in before batch jobs."],"tags":["upwork","browser-automation","page-evaluation-failed","nuxt-state","retryable"],"backgroundTag":"page-evaluation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}