{"record":{"id":"9d56823151b1ffe4","repo":"alyssaxuu/screenity","slug":"chrome-offscreen-api-unavailable","errorCode":null,"errorMessage":"chrome.offscreen API unavailable","messagePattern":"chrome\\.offscreen API unavailable","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/Background/offscreen/createCloudRecorderOffscreen.js","lineNumber":6,"sourceCode":"// Offscreen doc host for the recorder; immune to background-tab freeze/discard.\n// ?cloud=1 renders <CloudRecorder/>, else <Recorder/>. Chrome allows only one\n// offscreen doc per extension, so any existing one is closed first.\nexport const createCloudRecorderOffscreen = async ({ cloud = true } = {}) => {\n  if (!chrome.offscreen || typeof chrome.offscreen.createDocument !== \"function\") {\n    throw new Error(\"chrome.offscreen API unavailable\");\n  }\n\n  try {\n    const contexts = await chrome.runtime.getContexts({});\n    const hasOffscreen = (contexts || []).some(\n      (c) => c.contextType === \"OFFSCREEN_DOCUMENT\",\n    );\n    if (hasOffscreen) {\n      await chrome.offscreen.closeDocument();\n    }\n  } catch (err) {\n    // non-fatal; still attempt create, a stale doc surfaces as a create error\n    console.warn(\"[createCloudRecorderOffscreen] pre-close failed\", err);\n  }\n\n  await chrome.offscreen.createDocument({\n    url: cloud ? \"offscreenrecorder.html?cloud=1\" : \"offscreenrecorder.html\",\n    reasons: [\"USER_MEDIA\", \"DISPLAY_MEDIA\", \"BLOBS\", \"WORKERS\"],","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/Background/offscreen/createCloudRecorderOffscreen.js#L1-L24","documentation":"Guard in createCloudRecorderOffscreen: chrome.offscreen (or createDocument) is undefined, meaning the browser lacks Offscreen Documents support or the manifest is missing the 'offscreen' permission. The recorder's offscreen host cannot be created, so background-recording via offscreen doc is impossible in this environment.","triggerScenarios":"Thrown at src/pages/Background/offscreen/createCloudRecorderOffscreen.js:6 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add \"offscreen\" to the manifest permissions","Feature-detect and fall back to rendering the recorder in a tab or extension page","Inform users on browsers without offscreen support that the feature is unavailable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"512606387b8d07dda5e63bb428bd063f0a2a3ed0","analyzedAt":"2026-09-02T20:59:09.419Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}