Open Bug 1826243 Opened 1 year ago Updated 1 year ago

Unable to use Blob-compatible class with fetch

Categories

(Core :: DOM: File, enhancement)

Firefox 105
enhancement

Tracking

()

UNCONFIRMED

People

(Reporter: amaret93, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:105.0) Gecko/20100101 Firefox/105.0

Steps to reproduce:

I tried to implement a Blob-compatible class to use it with fetch API.

This WebBlob class extends the original Blob and implements the same API.

The purpose is to avoid loading huge file directly into RAM and to be able to use WebBlob instance like Blob instance as body content for POST request made with fetch

I setup a repository to reproduce this behavior https://github.com/Aschen/webblob-experiment

Actual results:

When a WebBlob is passed in the body of fetch request, then the server receive an empty body.

Expected results:

The server should have received a body containing the remote resource pointed by the WebBlob

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Networking' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Networking
Product: Firefox → Core

Not sure if this is something that is actually supposed to work or not.

Component: DOM: Networking → DOM: File

Not sure if this is something that is actually supposed to work or not.

Since Blob is a Javascript class, I thought that by implementing the same interface and actually extends from the original Blob would be enough to use it as a replacement in other browser API but maybe it's not possible.

I'm trying to understand if it's intended or not, why it's not working and eventually how could we make this work.

For the record, I also opened a ticket in Chromium https://bugs.chromium.org/p/chromium/issues/detail?id=1430298

Just for info, inheriting Blob does work with the native fetch inside Node.js

A nice benefit of this working would be to upload streaming data with fetch if we know size in advance, and without requirements for HTTP2 on the backend.

More context here, at HuggingFace we provide a concept called "Spaces" which are web application linked to a Git repository and automatically deployed.

A common usage is to copy model related files between two or more applications. Files are downloaded from an URL on "Space A" and then uploaded on "Space B".

Actually the whole file has to be downloaded in RAM which can cause issues, especially in machine learning since models weight can be quite heavy.

Example here https://huggingface.co/spaces/huggingfacejs/push-model-from-web

You need to log in before you can comment on or make changes to this bug.