{"record":{"id":"b3bbca6c1fdf7892","repo":"alyssaxuu/screenity","slug":"failed-to-create-scene-errortext","errorCode":null,"errorMessage":"Failed to create scene: ${errorText}","messagePattern":"Failed to create scene: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/CloudRecorder/CloudRecorder.jsx","lineNumber":6280,"sourceCode":"            projectId,\n            sceneId,\n          });\n          logDebugEvent(\"scene-recovered\", {\n            projectId,\n            sceneId,\n          });\n          sceneOutcome = \"recovered\";\n          shouldIncrementMultiSceneCount = true;\n        } else {\n          logDebugEvent(\"scene-create-failed\", {\n            projectId,\n            sceneId,\n            error: errorText,\n          });\n          await setSceneCreateStatus(sceneId, \"failed\", {\n            error: errorText,\n          });\n          throw new Error(`Failed to create scene: ${errorText}`);\n        }\n      } else {\n        // Dispatch editor-ready right after the 201; housekeeping\n        // (setSceneCreateStatus / removePendingScene / etc.) runs in\n        // parallel below since nothing in the handoff reads it.\n        sceneOutcome = \"created\";\n        shouldIncrementMultiSceneCount = true;\n\n        if (multiMode && shouldIncrementMultiSceneCount) {\n          // Multi needs count + lastSceneId persisted before\n          // reopen-popup-multi fires; that handler reads them.\n          // reads them. Keep this awaited path for multi.\n          await chrome.storage.local.set({\n            multiSceneCount: multiSceneCount + 1,\n            multiLastSceneId: sceneId,\n          });\n          chrome.runtime.sendMessage({\n            type: \"reopen-popup-multi\",","sourceCodeStart":6262,"sourceCodeEnd":6298,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/CloudRecorder/CloudRecorder.jsx#L6262-L6298","documentation":"CloudRecorder throws this after the background service worker's scene-create request returns a non-OK response AND the recoverScene() fallback also fails. The errorText is the raw response text or SW error forwarded from the create-scene API call, so the message surfaces the server/backend reason the scene could not be created.","triggerScenarios":"The SW-mediated create-scene POST (after one automatic retry for 'no-bg-response'/'bg-timeout') returns res.ok === false, and recoverScene() with the uploaded screen/camera/audio mediaIds also returns { ok: false }; the code marks the scene 'failed' via setSceneCreateStatus and rethrows the server's error text.","commonSituations":"Backend 4xx/5xx on the scene-create endpoint (auth token expired, invalid projectId, media still processing), service worker killed mid-request so only the error string comes back, or recover-scene endpoint rejecting because mediaIds are missing or not yet linked.","solutions":["Read errorText in the message to identify the exact server-side rejection (auth, 404 project, 500)","Verify the user session/auth token is valid and the projectId exists before starting the recording","Check that screen/camera/audio media uploads completed and mediaIds are populated in uploadMeta","Retry the recording; the recoverScene fallback already ran, so transient backend issues will usually succeed on a new attempt","Inspect setSceneCreateStatus(sceneId, 'failed', {error}) journal for the stored failure detail"],"exampleFix":"// before\nthrow new Error(`Failed to create scene: ${errorText}`);\n// after\nif (recoverResult.status === 401 || /unauthor|token/i.test(errorText)) {\n  await requestReauth();\n}\nthrow new Error(`Failed to create scene: ${errorText}`);","handlingStrategy":"try-catch","validationCode":"const swRes = await sendSceneCreateOnce();\nif (!swRes?.ok && !(await hasValidSession())) {\n  throw new Error(\"Session expired before scene create; re-authenticate first\");\n}\nif (!uploadMeta.screen?.mediaId && !uploadMeta.camera?.mediaId) {\n  throw new Error(\"No uploaded media to attach to scene; abort before create\");\n}","typeGuard":"function hasStreamId(res) {\n  return typeof res === \"object\" && res !== null && \"ok\" in res && res.ok === true;\n}\nfunction isRecoverableSceneCreate(res) {\n  return res != null && typeof res.error === \"string\" && res.error.length > 0;\n}","tryCatchPattern":"try {\n  await createSceneViaSW(payload);\n} catch (err) {\n  if (/Failed to create scene:/.test(err.message)) {\n    const serverReason = err.message.replace(\"Failed to create scene: \", \"\");\n    if (/unauthor|401|token/i.test(serverReason)) await requestReauth();\n    else await retryWithBackoff(() => createSceneViaSW(payload));\n  } else throw err;\n}","preventionTips":["Validate auth/session and projectId exist before capturing media","Ensure media uploads complete and mediaIds are set before attempting scene create","Reuse the built-in recoverScene fallback and only surface the error when recovery also fails","Persist setSceneCreateStatus 'failed' journal entries so failures are diagnosable later"],"tags":["api","backend","recording-pipeline","chrome-extension"],"backgroundTag":"scene-create-failed","analyzedSha":"512606387b8d07dda5e63bb428bd063f0a2a3ed0","analyzedAt":"2026-09-02T20:59:09.419Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}