Merge pull request #836 from shocknet/relay-reconnect

Relay reconnect + throw sub p errs
This commit is contained in:
Justin (shocknet) 2025-09-18 16:05:01 -04:00 committed by GitHub
commit c31360b0cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 3 deletions

View file

@ -184,9 +184,11 @@ export default class Handler {
log("connected, subbing...") log("connected, subbing...")
relay.onclose = (() => { relay.onclose = (() => {
log("relay disconnected, will try to reconnect") log("relay disconnected, will try to reconnect in 2 seconds")
relay.close() relay.close()
this.Connect() setTimeout(() => {
this.Connect()
}, 2000)
}) })
const appIds = Object.keys(this.apps) const appIds = Object.keys(this.apps)

View file

@ -16,7 +16,10 @@ export default class NostrSubprocess {
constructor(settings: NostrSettings, utils: Utils, eventCallback: EventCallback) { constructor(settings: NostrSettings, utils: Utils, eventCallback: EventCallback) {
this.utils = utils this.utils = utils
this.childProcess = fork("./build/src/services/nostr/handler") this.childProcess = fork("./build/src/services/nostr/handler")
this.childProcess.on("error", console.error) this.childProcess.on("error", (error) => {
console.error("nostr subprocess error")
throw error
})
this.childProcess.on("message", (message: ChildProcessResponse) => { this.childProcess.on("message", (message: ChildProcessResponse) => {
switch (message.type) { switch (message.type) {
case 'ready': case 'ready':

View file

@ -58,6 +58,7 @@ export class StorageInterface extends EventEmitter {
this.process.on('error', (error: Error) => { this.process.on('error', (error: Error) => {
console.error('Storage processor error:', error); console.error('Storage processor error:', error);
this.isConnected = false; this.isConnected = false;
throw error
}); });
this.process.on('exit', (code: number) => { this.process.on('exit', (code: number) => {

View file

@ -113,6 +113,7 @@ class TlvFilesStorageProcessor {
process.on('error', (error: Error) => { process.on('error', (error: Error) => {
console.error('Error in tlv files storage processor:', error); console.error('Error in tlv files storage processor:', error);
throw error
}); });
this.wrtc = new webRTC(t => { this.wrtc = new webRTC(t => {