diff options
author | Heyang Zhou <zhy20000919@hotmail.com> | 2023-12-22 05:04:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-22 05:04:17 +0800 |
commit | 3fb4f3fe5a18916aa95f8b035ca994c290c173dc (patch) | |
tree | 0b7640ab4939a794bdf7ae66d6e8b4fb74943c9a /cli/tests | |
parent | 760af934d9b4bf8d0ab7f47263dd7cb9675db7a5 (diff) |
fix(unstable): kv watch should stop when db is closed (#21665)
Fixes #21634.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/kv_test.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/tests/unit/kv_test.ts b/cli/tests/unit/kv_test.ts index 28c913f21..4963882e1 100644 --- a/cli/tests/unit/kv_test.ts +++ b/cli/tests/unit/kv_test.ts @@ -2248,3 +2248,23 @@ dbTest("set with key versionstamp suffix", async (db) => { "expected string, number, bigint, ArrayBufferView, boolean", ); }); + +Deno.test({ + name: "watch should stop when db closed", + async fn() { + const db = await Deno.openKv(":memory:"); + + const watch = db.watch([["a"]]); + const completion = (async () => { + for await (const _item of watch) { + // pass + } + })(); + + setTimeout(() => { + db.close(); + }, 100); + + await completion; + }, +}); |