diff --git a/kv/src/kv.ts b/kv/src/kv.ts index 4c29ea57..710ba375 100644 --- a/kv/src/kv.ts +++ b/kv/src/kv.ts @@ -797,6 +797,19 @@ export class Bucket implements KV { qi.push(fn); }); + (async () => { + for await (const s of iter.status()) { + switch (s.type) { + // if we get a heartbeat we got all the keys + case "heartbeat": + qi.push(() => { + qi.stop(); + }); + break; + } + } + })().then(); + // if they break from the iterator stop the consumer qi.iterClosed.then(() => { iter.stop();