toeverything/AFFiNE · error

Failed to read mobile payload file: ${filePath} (status ${re

Error message

Failed to read mobile payload file: ${filePath} (status ${response.status})

What it means

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).

Source

Thrown at packages/frontend/apps/mobile-shared/src/nbstore/payload.ts:126

  if (parentDir === 'tmp') {
    return (
      parts[0] === 'tmp' ||
      (parts[0] === 'private' && parts[1] === 'var' && parts[2] === 'tmp')
    );
  }

  if (parentDir === 'T') {
    return parts[0] === 'var' && parts[1] === 'folders';
  }

  return false;
}

async function readTokenPayload(filePath: string): Promise<Uint8Array> {
  const response = await fetch(Capacitor.convertFileSrc(filePath));
  if (!response.ok) {
    throw new Error(
      `Failed to read mobile payload file: ${filePath} (status ${response.status})`
    );
  }

  return new Uint8Array(await response.arrayBuffer());
}

export interface DecodePayloadOptions {
  onTokenReadFailure?: (error: Error) => Promise<string | null | undefined>;
}

export async function decodePayload(
  data: string,
  prefix: string,
  options?: DecodePayloadOptions
): Promise<Uint8Array> {
  if (!data.startsWith(prefix)) {
    return base64ToUint8Array(data);

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Confirm the payload file still exists in the cache directory and retry the read.
  2. Handle non-200 responses by re-uploading the payload or surfacing the server error to the user.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: 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.

Common situations: 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.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/2c18cb8553e65a8e. Report an issue: GitHub.