Skip to content

bug: Reading large images via the asset protocol fails and is reported as "Invalid file type" #261

Description

@monon999

Version: 2.0.23

Describe the Bug

A 23.3 MB PNG (5120x5120, produced by ComfyUI) cannot be attached. The DevTools console shows:

Failed to read dropped image  F:\...\ComfyUI_20260807-055037_00001_.png  TypeError: Failed to fetch

The same failure occurs through the file picker (Failed to read file: TypeError: Failed to fetch), since both paths go through readImageAttachmentFromPath.

I narrowed it down in the DevTools console:

const r = await fetch('http://asset.localhost/' + encodeURIComponent(path));
r.status                           // 200
r.headers.get('content-length')    // 24449006
await r.blob()                     // Uncaught TypeError: Failed to fetch

The request itself succeeds and the correct content-length comes back — the failure happens while reading the response body. Images under 10 MB attach without any problem.

Separately, the message shown to the user is "Invalid file type (only JPEG, JPG, PNG, WEBP allowed)", because the catch in prepareImageAttachmentsFromPaths routes every read failure into invalidType. The file is a plain .png, so this message sent me looking in entirely the wrong direction. Surfacing the actual error, or at least a distinct "failed to read" case, would help a lot.

Steps to Reproduce

  1. Prepare a PNG larger than ~20 MB (mine is 5120x5120, 23.3 MB).
  2. Drag and drop it onto the chat input, or attach it via the file picker.
  3. The attachment is rejected with "Invalid file type", and the console logs TypeError: Failed to fetch.

Screenshots / Logs

Image

Operating System

  • MacOS
  • Windows
  • Linux

Related: #262

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions