toeverything/AFFiNE · error · StorageQuotaExceeded

storage_quota_exceeded

storage_quota_exceeded

Error message

You have exceeded your storage quota.

What it means

Sibling of 313: thrown when checkExceeded(0) reports storageQuotaExceeded. The workspace's total storage usage already exceeds the plan's storage quota, so the blob upload is refused before any bytes are read.

Source

Thrown at packages/backend/server/src/core/workspaces/resolvers/blob.ts:190

  async setBlob(
    @CurrentUser() user: CurrentUser,
    @Args('workspaceId') workspaceId: string,
    @Args({ name: 'blob', type: () => GraphQLUpload })
    blob: FileUpload
  ) {
    await this.ac
      .user(user.id)
      .workspace(workspaceId)
      .assert('Workspace.Blobs.Write');

    const checkExceeded =
      await this.quota.getWorkspaceQuotaCalculator(workspaceId);

    let result = checkExceeded(0);
    if (result?.blobQuotaExceeded) {
      throw new BlobQuotaExceeded();
    } else if (result?.storageQuotaExceeded) {
      throw new StorageQuotaExceeded();
    }

    const buffer = await readBuffer(blob.createReadStream(), checkExceeded);

    await this.storage.put(workspaceId, blob.filename, buffer);
    return blob.filename;
  }

  @Mutation(() => BlobUploadInit)
  async createBlobUpload(
    @CurrentUser() user: CurrentUser,
    @Args('workspaceId') workspaceId: string,
    @Args('key') key: string,
    @Args('size', { type: () => Int }) size: number,
    @Args('mime') mime: string
  ): Promise<BlobUploadInit> {
    await this.ac
      .user(user.id)

View on GitHub (pinned to 26c515e050)

Solutions

  1. Reduce storage usage (blobs, docs, history) below quota.
  2. Upgrade the plan's storage quota.
  3. Ensure usage metrics feeding the calculator are up to date.
  4. Surface storage usage in the UI.

Example fix

// before
await storage.put(ws, file.name, buf)
// after
const calc = await quota.getWorkspaceQuotaCalculator(ws)
if (calc(0)?.storageQuotaExceeded) return promptStorageUpgrade()
Defensive patterns

Strategy: validation

Validate before calling

const calc = await quota.getWorkspaceQuotaCalculator(workspaceId)
if (calc(0)?.storageQuotaExceeded) return promptStorageUpgrade()

Try / catch

try { await uploadBlob(file) } catch (e) {
  if (e.code === 'storage_quota_exceeded') promptStorageUpgrade()
  else throw e
}

Prevention

When it happens

Trigger: The setBlob mutation when the workspace is already over its total storage quota (calculator at size 0).

Common situations: Plan downgrade; large doc/blob accumulation; stale usage metrics; multi-tenant shared storage limits.

Related errors


AI-assisted analysis of toeverything/AFFiNE@26c515e050 (2026-08-12). Data as JSON: /api/errors/76c76f40d48728fa. Report an issue: GitHub.