Skip to content

Commit 6efc894

Browse files
committed
Add heartbeat handling to key iteration
Introduce a heartbeat case to handle key iteration status updates. This ensures proper key fetching and stops the iteration appropriately upon receiving a heartbeat. Signed-off-by: Alberto Ricart <[email protected]>
1 parent 3d448c9 commit 6efc894

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: kv/src/kv.ts

+13
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,19 @@ export class Bucket implements KV {
899899
},
900900
});
901901

902+
(async () => {
903+
for await(const s of iter.status()) {
904+
switch(s.type) {
905+
// if we get a heartbeat we got all the keys
906+
case "heartbeat":
907+
keys.push(() => {
908+
keys.stop();
909+
})
910+
break;
911+
}
912+
}
913+
})().then();
914+
902915
iter.closed().then(() => {
903916
keys.push(() => {
904917
keys.stop();

0 commit comments

Comments
 (0)