@@ -295,19 +295,31 @@ suite("stream<T> lifts", () => {
295295 await checkStreamValues ( { stream, vals, typeName : "result<string>" , assertEqFn : assert . deepEqual } ) ;
296296 } ) ;
297297
298- test ( "example-resource" , async ( ) => {
298+ test . only ( "example-resource" , async ( ) => {
299299 assert . instanceOf ( instance [ "jco:test-components/get-stream-async" ] . getStreamExampleResourceOwn , AsyncFunction ) ;
300+ const disposeSymbol = Symbol . dispose || Symbol . for ( "dispose" ) ;
301+
300302 let vals = [ 2 , 1 , 0 ] ;
301303 let stream = await instance [ "jco:test-components/get-stream-async" ] . getStreamExampleResourceOwn ( vals ) ;
302- const disposeSymbol = Symbol . dispose || Symbol . for ( "dispose" ) ;
303- let numDisposed = 0 ;
304+ const resources = [ ] ;
304305 for ( const expectedResourceId of vals ) {
305306 const resource = await stream . next ( ) ;
306307 assert . isNotNull ( resource ) ;
307308 assert . instanceOf ( resource , instance [ "jco:test-components/get-stream-async" ] . ExampleGuestResource ) ;
308309 assert . strictEqual ( resource . getId ( ) , expectedResourceId ) ;
309- assert . strictEqual ( resource . getId ( ) , await resource . getIdAsync ( ) ) ;
310+ resources . push ( resource ) ;
311+ }
312+
313+ // NOTE: we have to pull all objects out of the stream and drop the stream,
314+ // *before* attempting to call async functions on the resources, to avoid
315+ // recursive re-entrancy into the same component instance
316+
317+ // TODO(fix): streams should be droppable from the host side...
318+ // otherwise we can't force the writer to give up writing?
310319
320+ let numDisposed = 0 ;
321+ for ( const resource of resources ) {
322+ assert . strictEqual ( resource . getId ( ) , await resource . getIdAsync ( ) ) ;
311323 assert . doesNotThrow ( ( ) => resource [ disposeSymbol ] ( ) ) ;
312324 numDisposed += 1 ;
313325 assert . strictEqual (
0 commit comments