@@ -2077,32 +2077,34 @@ function startAsyncIterable<T>(
2077
2077
}
2078
2078
} ,
2079
2079
} ;
2080
- const iterable : $AsyncIterable < T , T , void > = {
2081
- [ ASYNC_ITERATOR ] ( ) : $AsyncIterator < T , T , void > {
2082
- let nextReadIndex = 0 ;
2083
- return createIterator ( arg => {
2084
- if ( arg !== undefined ) {
2085
- throw new Error (
2086
- 'Values cannot be passed to next() of AsyncIterables passed to Client Components.' ,
2080
+
2081
+ const iterable : $AsyncIterable < T , T , void > = ({ } : any);
2082
+ // $FlowFixMe[cannot-write]
2083
+ iterable[ASYNC_ITERATOR] = (): $AsyncIterator< T , T , void > => {
2084
+ let nextReadIndex = 0 ;
2085
+ return createIterator ( arg => {
2086
+ if ( arg !== undefined ) {
2087
+ throw new Error (
2088
+ 'Values cannot be passed to next() of AsyncIterables passed to Client Components.' ,
2089
+ ) ;
2090
+ }
2091
+ if ( nextReadIndex === buffer . length ) {
2092
+ if ( closed ) {
2093
+ // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
2094
+ return new ReactPromise (
2095
+ INITIALIZED ,
2096
+ { done : true , value : undefined } ,
2097
+ null ,
2098
+ response ,
2087
2099
) ;
2088
2100
}
2089
- if ( nextReadIndex === buffer . length ) {
2090
- if ( closed ) {
2091
- // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
2092
- return new ReactPromise (
2093
- INITIALIZED ,
2094
- { done : true , value : undefined } ,
2095
- null ,
2096
- response ,
2097
- ) ;
2098
- }
2099
- buffer [ nextReadIndex ] =
2100
- createPendingChunk < IteratorResult < T , T >> ( response ) ;
2101
- }
2102
- return buffer [ nextReadIndex ++ ] ;
2103
- } ) ;
2104
- } ,
2101
+ buffer [ nextReadIndex ] =
2102
+ createPendingChunk < IteratorResult < T , T >> ( response ) ;
2103
+ }
2104
+ return buffer [ nextReadIndex ++ ] ;
2105
+ } ) ;
2105
2106
} ;
2107
+
2106
2108
// TODO: If it's a single shot iterator we can optimize memory by cleaning up the buffer after
2107
2109
// reading through the end, but currently we favor code size over this optimization.
2108
2110
resolveStream(
0 commit comments