Skip to content

Commit

Permalink
history for kv has the same issue - if values are purged in flight, t…
Browse files Browse the repository at this point in the history
…he iteration may hang.

Signed-off-by: Alberto Ricart <[email protected]>
  • Loading branch information
aricart committed Feb 4, 2025
1 parent 92407d9 commit 4b12ef9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kv/src/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4b12ef9

Please sign in to comment.