@@ -1174,16 +1174,12 @@ function fetchFinale (fetchParams, response) {
11741174
11751175 const byteStream = new ReadableStream ( {
11761176 readableStream : transformStream . readable ,
1177+ async start ( ) {
1178+ this . _bodyReader = this . readableStream . getReader ( )
1179+ } ,
11771180 async pull ( controller ) {
1178- // TODO(mcollina): removen this block, not sure why pull() is called twice
1179- if ( this . readableStream . locked ) {
1180- return
1181- }
1182-
1183- const reader = this . readableStream . getReader ( )
1184-
11851181 while ( controller . desiredSize >= 0 ) {
1186- const { done, value } = await reader . read ( )
1182+ const { done, value } = await this . _bodyReader . read ( )
11871183
11881184 if ( done ) {
11891185 queueMicrotask ( ( ) => readableStreamClose ( controller ) )
@@ -1985,8 +1981,8 @@ async function httpNetworkFetch (
19851981
19861982 // 11. Let pullAlgorithm be an action that resumes the ongoing fetch
19871983 // if it is suspended.
1988- const pullAlgorithm = ( ) => {
1989- fetchParams . controller . resume ( )
1984+ const pullAlgorithm = async ( ) => {
1985+ await fetchParams . controller . resume ( )
19901986 }
19911987
19921988 // 12. Let cancelAlgorithm be an algorithm that aborts fetchParams’s
@@ -2101,9 +2097,7 @@ async function httpNetworkFetch (
21012097 // into stream.
21022098 const buffer = new Uint8Array ( bytes )
21032099 if ( buffer . byteLength ) {
2104- try {
2105- fetchParams . controller . controller . enqueue ( buffer )
2106- } catch { }
2100+ fetchParams . controller . controller . enqueue ( buffer )
21072101 }
21082102
21092103 // 8. If stream is errored, then terminate the ongoing fetch.
@@ -2114,7 +2108,7 @@ async function httpNetworkFetch (
21142108
21152109 // 9. If stream doesn’t need more data ask the user agent to suspend
21162110 // the ongoing fetch.
2117- if ( ! fetchParams . controller . controller . desiredSize ) {
2111+ if ( fetchParams . controller . controller . desiredSize <= 0 ) {
21182112 return
21192113 }
21202114 }
0 commit comments