File tree 1 file changed +20
-11
lines changed
1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -1764,19 +1764,28 @@ function createInlineDataStream(
1764
1764
1765
1765
if ( ! dataStreamFinished && dataStream ) {
1766
1766
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 )
1773
1782
}
1774
- controller . enqueue ( value )
1783
+ } catch ( err ) {
1784
+ controller . error ( err )
1775
1785
}
1776
- } catch ( err ) {
1777
- controller . error ( err )
1778
- }
1779
- } ) ( )
1786
+ res ( )
1787
+ } , 0 )
1788
+ )
1780
1789
}
1781
1790
} ,
1782
1791
flush ( ) {
You can’t perform that action at this time.
0 commit comments