diff --git a/package-lock.json b/package-lock.json index 107fcd31..f759c7fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18640,7 +18640,7 @@ }, "packages/local": { "name": "@tableland/local", - "version": "3.0.1", + "version": "3.0.2", "hasInstallScript": true, "license": "MIT AND Apache-2.0", "dependencies": { diff --git a/packages/local/package.json b/packages/local/package.json index 50ff5aef..1d3a4f74 100644 --- a/packages/local/package.json +++ b/packages/local/package.json @@ -1,6 +1,6 @@ { "name": "@tableland/local", - "version": "3.0.1", + "version": "3.0.2", "description": "Tooling to start a sandboxed Tableland network.", "repository": { "type": "git", diff --git a/packages/local/src/main.ts b/packages/local/src/main.ts index 733ecb49..aa3df037 100644 --- a/packages/local/src/main.ts +++ b/packages/local/src/main.ts @@ -34,6 +34,7 @@ class LocalTableland { readonly defaultRegistryPort: number = 8545; #_readyResolves: Array<(value: unknown) => any> = []; + stopping: boolean = false; config; initEmitter; ready: boolean = false; @@ -349,12 +350,24 @@ class LocalTableland { async shutdown(): Promise { try { + // need to ensure shutdown isn't run twice in parallel since SIGINT is + // sent repeatedly depending on where it originates + if (this.stopping) { + console.log("stopping..."); + return; + } + + this.stopping = true; await this.shutdownValidator(); await this.shutdownRegistry(); this.#_cleanup(); + this.stopping = false; + this.ready = false; } catch (err: any) { this.#_cleanup(); + this.stopping = false; + this.ready = false; throw new Error( `unexpected error during shutdown: ${err.message as string}` );