<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>23772</bug_id>
          
          <creation_ts>2013-11-08 08:21:57 +0000</creation_ts>
          <short_desc>Just return read result when there&apos;s data synchronously readable</short_desc>
          <delta_ts>2013-12-05 19:46:02 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>Streams API</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Takeshi Yoshino">tyoshino</reporter>
          <assigned_to name="Takeshi Yoshino">tyoshino</assigned_to>
          <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>96024</commentid>
    <comment_count>0</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2013-11-08 08:21:57 +0000</bug_when>
    <thetext>It&apos;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&apos;s network stack code (ERR_IO_PENDING).

----

It&apos;s efficient, but I got feedback against this from Elliott. Quoting.

- It&apos;s really weird that sometimes this thing is a Promise and sometimes it isn&apos;t.
- It also doesn&apos;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&lt;Result&gt; 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&apos;s slower.
- I&apos;d suggest always returning a Promise and dealing with it at microtask time for the &quot;synchronous&quot; case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96105</commentid>
    <comment_count>1</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2013-11-11 06:05:24 +0000</bug_when>
    <thetext>One more feedback from Google Maps developer against sync/async hybrid method.

I&apos;d like to revert this back to always Promise approach.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96146</commentid>
    <comment_count>2</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2013-11-11 22:02:21 +0000</bug_when>
    <thetext>Revert committed. Now read/pipe methods always return Promises again.
https://dvcs.w3.org/hg/streams-api/raw-file/tip/preview.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97212</commentid>
    <comment_count>3</comment_count>
    <who name="Takeshi Yoshino">tyoshino</who>
    <bug_when>2013-12-05 19:46:02 +0000</bug_when>
    <thetext>Preview ver merged into ED</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>