New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 594979 link

Starred by 3 users

Issue metadata

Status: Duplicate
Merged: issue 2016
Owner: ----
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

Fetch API promise does not resolve as long as content is smaller than 1024 bytes

Reported by matthias...@googlemail.com, Mar 15 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0

Example URL:
https://gist.github.com/Matthias247/60f700a5faea1ccc1006

Steps to reproduce the problem:
1. Start a (HTTP2) server which streams data slowly to chrome, e.g. 1byte/s 
2. Make a Fetch API call to the to server and try to access the streamed body through the fetch body stream

What is the expected behavior?
The promise should resolve directly after the complete HTTP2 header block which marks the start of the response stream was received. I should directly be able to access the content of the stream as soon as a related DATA frame arrives. If I send single bytes from the server in 1 second intervals like shown in the linked server code then I should be able to use that data in the client without a big delay.

What went wrong?
The promise returned from fetch is not resolved until not at least a certain amount of bytes were received. That number seems to be 1024.
If at the beginning of the response stream a big data block (>= 1024 bytes) is returned at once then the promise will be resolved immediately.

Did this work before? N/A 

Chrome version: 49, Canary  Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version: 

I'm experimenting with using HTTP2 for streaming and synchronization purposes (similar to gRPC). The idea is that everytime I have a state update on the server I write that in a serialized form to the HTTP response stream and can pick it through processing the stream on the client. However this currently doesn't seem to work when when the object size is small, as I then would need lots of updates until the first one would be actually visible to the client.
 
Another update after a test: If the response stream ends then the promise will always be resolved, even before the content size reaches that treshold. So the problem only exists for people that want to exploit the streaming behavior.
Cc: igrigo...@chromium.org y...@yoav.ws mmenke@chromium.org slightlyoff@chromium.org
Components: -Internals>Network Blink>Network>FetchAPI Internals>Network>HTTP
Mime sniffing strikes again.

Ilya, Yoav, Alex: Anyone want to figure out what Fetch should do regarding sniffing?

The code in question causing the delay is https://code.google.com/p/chromium/codesearch#chromium/src/content/browser/loader/mime_type_resource_handler.h
Labels: Te-NeedsFurtherTriage
Cc: tyoshino@chromium.org
Labels: -Pri-2 -Te-NeedsFurtherTriage Pri-3
I assume Fetch API would still skip content sniffing in X-Content-Type-Options: nosniff case. That being said, I'd love to get rid of this behavior for Fetch without requiring servers to have to opt in to it.


Status: Available (was: Unconfirmed)
I don't see anything about mime sniffing at https://github.com/whatwg/fetch/issues
Mergedinto: 2016
Status: Duplicate (was: Available)
Copied comments and people to bug 2016.
Components: Internals>Network
Components: -Internals>Network>HTTP

Sign in to add a comment