{"record":{"id":"2c18cb8553e65a8e","repo":"toeverything/AFFiNE","slug":"failed-to-read-mobile-payload-file-filepath-s","errorCode":null,"errorMessage":"Failed to read mobile payload file: ${filePath} (status ${response.status})","messagePattern":"Failed to read mobile payload file: (.+?) \\(status (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/frontend/apps/mobile-shared/src/nbstore/payload.ts","lineNumber":126,"sourceCode":"\n  if (parentDir === 'tmp') {\n    return (\n      parts[0] === 'tmp' ||\n      (parts[0] === 'private' && parts[1] === 'var' && parts[2] === 'tmp')\n    );\n  }\n\n  if (parentDir === 'T') {\n    return parts[0] === 'var' && parts[1] === 'folders';\n  }\n\n  return false;\n}\n\nasync function readTokenPayload(filePath: string): Promise<Uint8Array> {\n  const response = await fetch(Capacitor.convertFileSrc(filePath));\n  if (!response.ok) {\n    throw new Error(\n      `Failed to read mobile payload file: ${filePath} (status ${response.status})`\n    );\n  }\n\n  return new Uint8Array(await response.arrayBuffer());\n}\n\nexport interface DecodePayloadOptions {\n  onTokenReadFailure?: (error: Error) => Promise<string | null | undefined>;\n}\n\nexport async function decodePayload(\n  data: string,\n  prefix: string,\n  options?: DecodePayloadOptions\n): Promise<Uint8Array> {\n  if (!data.startsWith(prefix)) {\n    return base64ToUint8Array(data);","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/apps/mobile-shared/src/nbstore/payload.ts#L108-L144","documentation":"Thrown when the fetch of a locally converted file URL (Capacitor.convertFileSrc) for a mobile token payload returns a non-ok HTTP status, meaning the webview bridge could not serve the file from the device cache (missing file or access failure).","triggerScenarios":"Thrown in readTokenPayload when fetching the cached blob file via Capacitor.convertFileSrc returns a non-OK HTTP status, so the payload bytes cannot be read.","commonSituations":"Happens when the cached blob file was evicted or the OS denies access. decodePayload can retry through the onTokenReadFailure callback to fetch a fresh payload.","solutions":["Confirm the payload file still exists in the cache directory and retry the read.","Handle non-200 responses by re-uploading the payload or surfacing the server error to the user."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}