{"record":{"id":"c7f2f436734d7ec9","repo":"alyssaxuu/screenity","slug":"sign-in-failed","errorCode":null,"errorMessage":"Sign-in failed","messagePattern":"Sign-in failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/pages/Background/drive/handleSaveToDrive.js","lineNumber":330,"sourceCode":"      // chrome.identity hands back the same cached token even after the server\n      // revoked it, so without this the retry replays the dead token and the\n      // user is asked to sign in again on a loop.\n      // No-op on Edge, where signIn uses launchWebAuthFlow and the token was\n      // never in getAuthToken's cache. Raced against a timeout so a callback\n      // that never fires can't wedge the retry.\n      try {\n        const stale = await getAuthTokenFromStorage();\n        if (stale && chrome.identity?.removeCachedAuthToken) {\n          await Promise.race([\n            new Promise((resolve) =>\n              chrome.identity.removeCachedAuthToken({ token: stale }, resolve)\n            ),\n            new Promise((resolve) => setTimeout(resolve, 2000)),\n          ]);\n        }\n      } catch {}\n      const refreshed = await signIn();\n      if (!refreshed) throw new Error(\"Sign-in failed\");\n      await chrome.storage.local.set({ token: refreshed });\n      token = refreshed;\n    } else {\n      token = await getAuthTokenFromStorage();\n      if (!token) throw new Error(\"Sign-in failed\");\n    }\n\n    const folderId = await findOrCreateScreenityFolder(token);\n    const fileId = await uploadResumable(token, videoBlob, fileName, folderId);\n    if (!fileId) throw new Error(\"File ID missing after upload\");\n    return fileId;\n  };\n\n  try {\n    diagEvent(\"drive-upload-start\", {\n      blobSize: videoBlob.size,\n      blobType: videoBlob.type,\n    });","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/alyssaxuu/screenity/blob/512606387b8d07dda5e63bb428bd063f0a2a3ed0/src/pages/Background/drive/handleSaveToDrive.js#L312-L348","documentation":"In runUploadOnce's 401-recovery path, signIn() returned a falsy token after the cached auth token was evicted, meaning the user declined the consent prompt or the identity flow failed. Thrown so saveToDrive aborts instead of proceeding without a token.","triggerScenarios":"Thrown at src/pages/Background/drive/handleSaveToDrive.js:330 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Show a 'sign in to Google Drive' prompt and let the user retry interactively","Verify chrome.identity OAuth client IDs and scopes for Chrome and Edge variants","Catch this in saveToDrive and surface a user-facing message with a retry button"],"exampleFix":null,"handlingStrategy":"try-catch","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"}