{"record":{"id":"cd2c27b5e6005134","repo":"nexu-io/open-design","slug":"volcengine-poll-non-json-truncate-polltext-200","errorCode":null,"errorMessage":"volcengine poll non-JSON: ${truncate(pollText, 200)}","messagePattern":"volcengine poll non-JSON: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/index.ts","lineNumber":1494,"sourceCode":"  // mid-flight.\n  if (typeof onProgress === 'function') {\n    const mode = ctx.imageRef ? 'i2v' : 't2v';\n    onProgress(`volcengine ${mode} task ${taskId} accepted; polling status…`);\n  }\n  while (Date.now() - startedAt < maxMs) {\n    await sleep(4000);\n    const pollResp = await fetch(`${baseUrl}/contents/generations/tasks/${encodeURIComponent(taskId)}`, withMediaRequestInit(ctx, {\n      headers: { 'authorization': `Bearer ${credentials.apiKey}` },\n    }));\n    const pollText = await pollResp.text();\n    if (!pollResp.ok) {\n      throw new Error(`volcengine poll ${pollResp.status}: ${truncate(pollText, 240)}`);\n    }\n    let pollData: any;\n    try {\n      pollData = JSON.parse(pollText);\n    } catch {\n      throw new Error(`volcengine poll non-JSON: ${truncate(pollText, 200)}`);\n    }\n    lastStatus = pollData.status || '';\n    // Forward each poll tick. Heartbeat doubles as a \"command is alive\"\n    // signal for the agent's bash tool — the daemon's SSE stream emits\n    // an event for every line, which cc renders into the chat as live\n    // output so its watchdog never marks the call as hung.\n    if (typeof onProgress === 'function') {\n      const elapsedSec = Math.round((Date.now() - startedAt) / 1000);\n      onProgress(`volcengine task ${taskId} status=${lastStatus || 'pending'} (elapsed ${elapsedSec}s)`);\n    }\n    if (lastStatus === 'succeeded') {\n      videoUrl = pollData?.content?.video_url || null;\n      break;\n    }\n    if (lastStatus === 'failed' || lastStatus === 'cancelled') {\n      const reason = pollData?.error?.message || lastStatus;\n      throw new Error(`volcengine task ${lastStatus}: ${reason}`);\n    }","sourceCodeStart":1476,"sourceCodeEnd":1512,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/index.ts#L1476-L1512","documentation":"Thrown when `JSON.parse(pollText)` fails on a poll response. Same shape as the creation non-JSON error (424) but on the GET poll path: a 2xx HTML/gateway body instead of the expected `{status, content}` JSON.","triggerScenarios":"2xx poll response that isn't JSON. Gateway maintenance page returned mid-render, proxy HTML interstitial, or a transient HTML body from the Ark edge.","commonSituations":"(1) Mid-render gateway blip returning HTML; (2) proxy injection; (3) baseUrl misconfiguration.","solutions":["Retry the render; this is typically transient.","Inspect the truncated body to distinguish gateway HTML from a routing error.","Verify baseUrl/host reachability and that no proxy rewrites the response."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function looksLikeArkJson(text: string): boolean {\n  const head = text.slice(0, 100).trim();\n  return head.startsWith('{') || head.startsWith('[');\n}","typeGuard":null,"tryCatchPattern":"try { pollData = JSON.parse(pollText); }\ncatch { throw new Error(`volcengine poll non-JSON: ${truncate(pollText, 200)}`); }","preventionTips":["Retry the render on transient gateway HTML mid-poll.","Log response `Content-Type` to distinguish gateway HTML from real Ark JSON.","Keep `baseUrl` at the default Ark host unless you control the target."],"tags":["volcengine","ark","seedance","json","polling"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}