From b9a82f41b9361360856f9141fd56b7ad49301c08 Mon Sep 17 00:00:00 2001 From: Alex / KATT Date: Sat, 7 Oct 2023 16:47:58 +0200 Subject: [PATCH] fix: we should call `.close()` in async iterable (#50) --- src/async/handlers/tsonAsyncIterable.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/async/handlers/tsonAsyncIterable.ts b/src/async/handlers/tsonAsyncIterable.ts index 46a74d2e..0117d04b 100644 --- a/src/async/handlers/tsonAsyncIterable.ts +++ b/src/async/handlers/tsonAsyncIterable.ts @@ -36,21 +36,21 @@ export const tsonAsyncIterator: TsonAsyncType< switch (value[0]) { case ITERATOR_DONE: { + opts.close(); return; } case ITERATOR_ERROR: { + opts.close(); throw TsonPromiseRejectionError.from(value[1]); } case ITERATOR_VALUE: { yield value[1]; - break; + break; // <-- breaks the switch, not the loop } } } - - opts.close(); })(); }, key: "AsyncIterable",