Skip to content

Commit

Permalink
Switch network cleanup to beforeExit (#497)
Browse files Browse the repository at this point in the history
fixes #424
  • Loading branch information
Apollon77 authored Nov 8, 2023
1 parent 50202f5 commit f1d82f9
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ device
.catch(err => console.error(err));

process.on("SIGINT", () => {
// Clean up on CTRL-C
device
.stop()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ device
.catch(err => console.error(err));

process.on("SIGINT", () => {
// Clean up on CTRL-C
device
.stop()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ class ControllerNode {
new ControllerNode().start().catch(error => logger.error(error));

process.on("SIGINT", () => {
// Clean up on CTRL-C
// Pragmatic way to make sure the storage is correctly closed before the process ends.
storage
.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ device
.catch(err => console.error(err));

process.on("SIGINT", () => {
// Clean up on CTRL-C
device
.stop()
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ device
.catch(err => console.error(err));

process.on("SIGINT", () => {
// Clean up on CTRL-C
device
.stop()
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/matter-node.js/src/net/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ try {
if (error instanceof NoProviderError) {
Network.get = singleton(() => new NetworkNode());
// When we initialize anything we also need to make st is closed correctly
process.on("SIGINT", () => void Network.get().close());
process.on("beforeExit", () => void Network.get().close());
} else {
throw error;
}
Expand Down

0 comments on commit f1d82f9

Please sign in to comment.