toeverything/AFFiNE · error · OverSizeError

File size exceeds the ${formattedLimit}limit.

Error message

File size exceeds the ${formattedLimit}limit.

What it means

CloudBlobStorage.set() pre-checks the blob's byteLength against the workspace's per-file blob size limit (fetched via workspaceBlobQuotaQuery) and throws OverSizeError before any network upload starts. The message embeds the human-readable limit, e.g. 'File size exceeds the 10 MB limit.' This is a client-side fast-fail to avoid uploading a file the server will reject.

Source

Thrown at packages/common/nbstore/src/impls/cloud/blob.ts:135

      }

      return {
        key,
        data: new Uint8Array(await blob.arrayBuffer()),
        mime: blob.type,
        size: blob.size,
        createdAt: new Date(res.headers.get('last-modified') || Date.now()),
      };
    } catch (err) {
      throw new Error('blob download error: ' + err);
    }
  }

  override async set(blob: BlobRecord, signal?: AbortSignal) {
    try {
      const blobSizeLimit = await this.getBlobSizeLimit();
      if (blob.data.byteLength > blobSizeLimit) {
        throw new OverSizeError(this.humanReadableBlobSizeLimitCache);
      }

      const init = await this.connection.gql({
        query: createBlobUploadMutation,
        variables: {
          workspaceId: this.options.id,
          key: blob.key,
          size: blob.data.byteLength,
          mime: blob.mime,
        },
        context: { signal },
      });

      const upload = init.createBlobUpload;
      if (upload.alreadyUploaded) {
        return;
      }
      if (upload.method === BlobUploadMethod.GRAPHQL) {

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Reduce the file (compress images/video, split archives) below the limit stated in the message.
  2. On a self-hosted server, raise the limit: set AFFINE_BLOB_SIZE_LIMIT (bytes) in the server env and restart — the client fetches the quota dynamically.
  3. Check the workspace quota via storage.getBlobSizeLimit() in UI code and disable/warn on oversized picks before calling set.
  4. If the message shows no limit value, the cached human-readable limit was null — re-fetch quota or treat the server response as the source of truth.

Example fix

// before
await blobStorage.set({ key, data: fileBytes, mime: 'video/mp4' }); // throws

// after
const limit = await blobStorage.getBlobSizeLimit();
if (fileBytes.byteLength > limit) {
  notify(`Max file size is ${formatBytes(limit)}`);
} else {
  await blobStorage.set({ key, data: fileBytes, mime: 'video/mp4' });
}
Defensive patterns

Strategy: validation

Validate before calling

const limit = await blobStorage.getBlobSizeLimit();
if (file.size > limit) {
  throw new Error(`file too large: ${file.size} > limit ${limit}`);
}
await blobStorage.set({ key: nanoid(), data: bytes, mime });

Type guard

import { OverSizeError } from '@affine/nbstore/storage';
const isOverSize = (e: unknown): e is OverSizeError => e instanceof OverSizeError;

Try / catch

try { await blobStorage.set(rec); } catch (e) { if (e instanceof OverSizeError) { /* show 'file too large' with limit, offer compression */ return; } throw e; }

Prevention

When it happens

Trigger: blobStorage.set({ key, data, mime }) where data.byteLength exceeds the server's configured blob size limit; uploading large videos/binaries/PDFs to a self-hosted AFFiNE whose AFFINE_BLOB_SIZE_LIMIT is at the default 10MB.

Common situations: Self-hosted server with default (small) blob limit; users attaching screen recordings or design files; changing the server limit but the client caching the old humanReadableBlobSizeLimitCache; plan-level per-file caps on affine.cloud.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


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