-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): fixed a resource leak that was not apparent if the process…
…ing for status was in an async function - the loop would terminate, but the actual closing didn't finish so any code following the async loop didn't execute. also simplified handling of connection status listeners (listeners were tracked by the connection and the protocol - now only by the protocol), fixed a leak on dial where a promise was not cancelled for the wait between dial interval. (#137) fix(test): jetstream test was not really testing the status listener leaks Fix #134 Signed-off-by: Alberto Ricart <[email protected]>
- Loading branch information
Showing
4 changed files
with
52 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ import { assertEquals } from "jsr:@std/assert"; | |
import { delay } from "../src/internal_mod.ts"; | ||
import type { NatsConnectionImpl } from "../src/internal_mod.ts"; | ||
import { setup } from "test_helpers"; | ||
import { cleanup } from "../../test_helpers/mod.ts"; | ||
import { deferred } from "https://deno.land/x/[email protected]/nats-base-client/mod.ts"; | ||
|
||
Deno.test("events - close on close", async () => { | ||
const { ns, nc } = await setup(); | ||
|
@@ -148,3 +150,24 @@ Deno.test("events - ignore server updates", async () => { | |
await nc.close(); | ||
await NatsServer.stopAll(cluster, true); | ||
}); | ||
|
||
Deno.test("events - clean up", async () => { | ||
const { ns, nc } = await setup(); | ||
const finished = deferred(); | ||
|
||
const done = (async () => { | ||
for await (const _ of nc.status()) { | ||
// nothing | ||
} | ||
// let's make sure the iter broke... | ||
finished.resolve(); | ||
})(); | ||
await nc.reconnect(); | ||
await nc.close(); | ||
|
||
await finished; | ||
await done; | ||
await nc.closed(); | ||
|
||
await cleanup(ns, nc); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters