Skip to content

Commit f9f56a3

Browse files
authored
Merge pull request #146 from tablelandnetwork/joe/local-fix-shutdown
(local) ensure shutdown cannot be run repeatedly
2 parents 34f7e27 + 4aaa05d commit f9f56a3

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/local/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tableland/local",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "Tooling to start a sandboxed Tableland network.",
55
"repository": {
66
"type": "git",

packages/local/src/main.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class LocalTableland {
3434
readonly defaultRegistryPort: number = 8545;
3535

3636
#_readyResolves: Array<(value: unknown) => any> = [];
37+
stopping: boolean = false;
3738
config;
3839
initEmitter;
3940
ready: boolean = false;
@@ -349,12 +350,24 @@ class LocalTableland {
349350

350351
async shutdown(): Promise<void> {
351352
try {
353+
// need to ensure shutdown isn't run twice in parallel since SIGINT is
354+
// sent repeatedly depending on where it originates
355+
if (this.stopping) {
356+
console.log("stopping...");
357+
return;
358+
}
359+
360+
this.stopping = true;
352361
await this.shutdownValidator();
353362
await this.shutdownRegistry();
354363

355364
this.#_cleanup();
365+
this.stopping = false;
366+
this.ready = false;
356367
} catch (err: any) {
357368
this.#_cleanup();
369+
this.stopping = false;
370+
this.ready = false;
358371
throw new Error(
359372
`unexpected error during shutdown: ${err.message as string}`
360373
);

0 commit comments

Comments
 (0)