This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23772 - Just return read result when there's data synchronously readable
Summary: Just return read result when there's data synchronously readable
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Streams API (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Takeshi Yoshino
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-08 08:21 UTC by Takeshi Yoshino
Modified: 2013-12-05 19:46 UTC (History)
2 users (show)

See Also:


Attachments

Description Takeshi Yoshino 2013-11-08 08:21:57 UTC
It's currently implemented in preview ver.
https://dvcs.w3.org/hg/streams-api/raw-file/tip/preview.html

ByteStreamReadResult.data is a Promise when no data synchronously readable. Otherwise, data is actual data.

This is inspired by e.g. Chrome's network stack code (ERR_IO_PENDING).

----

It's efficient, but I got feedback against this from Elliott. Quoting.

- It's really weird that sometimes this thing is a Promise and sometimes it isn't.
- It also doesn't make sense that the data property is a Promise since the size and eof properties cannot be known until the promise is resolved so we might as well return Promise<Result> instead of a Result with a Promise property and a size/eof property external to it.
- Having the value jump between Promise and real data based on network latency is going to be very error prone for authors, you can probably write your code all one way if your network is fast and then see it fail when sometimes it's slower.
- I'd suggest always returning a Promise and dealing with it at microtask time for the "synchronous" case.
Comment 1 Takeshi Yoshino 2013-11-11 06:05:24 UTC
One more feedback from Google Maps developer against sync/async hybrid method.

I'd like to revert this back to always Promise approach.
Comment 2 Takeshi Yoshino 2013-11-11 22:02:21 UTC
Revert committed. Now read/pipe methods always return Promises again.
https://dvcs.w3.org/hg/streams-api/raw-file/tip/preview.html
Comment 3 Takeshi Yoshino 2013-12-05 19:46:02 UTC
Preview ver merged into ED