File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed
Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -1764,19 +1764,28 @@ function createInlineDataStream(
17641764
17651765 if ( ! dataStreamFinished && dataStream ) {
17661766 const dataStreamReader = dataStream . getReader ( )
1767- dataStreamFinished = ( async ( ) => {
1768- try {
1769- while ( true ) {
1770- const { done, value } = await dataStreamReader . read ( )
1771- if ( done ) {
1772- return
1767+
1768+ // We are buffering here for the inlined data stream because the
1769+ // "shell" stream might be chunkenized again by the underlying stream
1770+ // implementation, e.g. with a specific high-water mark. To ensure it's
1771+ // the safe timing to pipe the data stream, this extra tick is
1772+ // necessary.
1773+ dataStreamFinished = new Promise ( ( res ) =>
1774+ setTimeout ( async ( ) => {
1775+ try {
1776+ while ( true ) {
1777+ const { done, value } = await dataStreamReader . read ( )
1778+ if ( done ) {
1779+ return res ( )
1780+ }
1781+ controller . enqueue ( value )
17731782 }
1774- controller . enqueue ( value )
1783+ } catch ( err ) {
1784+ controller . error ( err )
17751785 }
1776- } catch ( err ) {
1777- controller . error ( err )
1778- }
1779- } ) ( )
1786+ res ( )
1787+ } , 0 )
1788+ )
17801789 }
17811790 } ,
17821791 flush ( ) {
You can’t perform that action at this time.
0 commit comments