handle exit signal when code is null

This commit is contained in:
boufni95 2026-01-28 15:53:57 +00:00
parent 44c55f3baa
commit 3b827626a6
3 changed files with 17 additions and 17 deletions

View file

@ -18,12 +18,12 @@ export default class NostrSubprocess {
this.log(ERROR, "nostr subprocess error", error) this.log(ERROR, "nostr subprocess error", error)
}) })
this.childProcess.on("exit", (code) => { this.childProcess.on("exit", (code, signal) => {
this.log(ERROR, `nostr subprocess exited with code ${code}`) this.log(ERROR, `nostr subprocess exited with code ${code} and signal ${signal}`)
if (!code) { if (code === 0) {
return return
} }
throw new Error(`nostr subprocess exited with code ${code}`) throw new Error(`nostr subprocess exited with code ${code} and signal ${signal}`)
}) })
this.childProcess.on("message", (message: ChildProcessResponse) => { this.childProcess.on("message", (message: ChildProcessResponse) => {
@ -69,6 +69,6 @@ export default class NostrSubprocess {
this.sendToChildProcess({ type: 'send', data, initiator, relays }) this.sendToChildProcess({ type: 'send', data, initiator, relays })
} }
Stop() { Stop() {
this.childProcess.kill() this.childProcess.kill(0)
} }
} }

View file

@ -61,13 +61,13 @@ export class StorageInterface extends EventEmitter {
this.isConnected = false; this.isConnected = false;
}); });
this.process.on('exit', (code: number) => { this.process.on('exit', (code: number, signal: string) => {
this.log(ERROR, `Storage processor exited with code ${code}`); this.log(ERROR, `Storage processor exited with code ${code} and signal ${signal}`);
this.isConnected = false; this.isConnected = false;
if (!code) { if (code === 0) {
return return
} }
throw new Error(`Storage processor exited with code ${code}`) throw new Error(`Storage processor exited with code ${code} and signal ${signal}`)
}); });
this.isConnected = true; this.isConnected = true;
@ -205,7 +205,7 @@ export class StorageInterface extends EventEmitter {
public disconnect() { public disconnect() {
if (this.process) { if (this.process) {
this.process.kill(); this.process.kill(0);
this.isConnected = false; this.isConnected = false;
this.debug = false; this.debug = false;
} }

View file

@ -53,13 +53,13 @@ export class TlvStorageFactory extends EventEmitter {
this.isConnected = false; this.isConnected = false;
}); });
this.process.on('exit', (code: number) => { this.process.on('exit', (code: number, signal: string) => {
this.log(ERROR, `Tlv Storage processor exited with code ${code}`); this.log(ERROR, `Tlv Storage processor exited with code ${code} and signal ${signal}`);
this.isConnected = false; this.isConnected = false;
if (!code) { if (code === 0) {
return return
} }
throw new Error(`Tlv Storage processor exited with code ${code}`) throw new Error(`Tlv Storage processor exited with code ${code} and signal ${signal}`)
}); });
this.isConnected = true; this.isConnected = true;
@ -173,7 +173,7 @@ export class TlvStorageFactory extends EventEmitter {
public disconnect() { public disconnect() {
if (this.process) { if (this.process) {
this.process.kill(); this.process.kill(0);
this.isConnected = false; this.isConnected = false;
this.debug = false; this.debug = false;
} }