Skip to content

Commit c9d0b1d

Browse files
committed
fix closing an already closed process
1 parent e6f7db9 commit c9d0b1d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export class Client {
3333
*/
3434
readonly #browser_process: Deno.ChildProcess;
3535

36+
#closed = false;
37+
3638
/**
3739
* The host and port that the websocket server is listening on
3840
*/
@@ -68,6 +70,10 @@ export class Client {
6870
errMsg?: string,
6971
errClass: { new (message: string): Error } = Error,
7072
) {
73+
if (this.#closed) {
74+
return;
75+
}
76+
7177
// Close browser process (also closes the ws endpoint, which in turn closes all sockets)
7278
const p = deferred();
7379
this.#socket.onclose = () => p.resolve();
@@ -76,6 +82,7 @@ export class Client {
7682
this.#browser_process.kill();
7783
await this.#browser_process.status;
7884
await p;
85+
this.#closed = true;
7986

8087
if (errMsg) {
8188
throw new errClass(errMsg);

0 commit comments

Comments
 (0)