]> jfr.im git - irc/freenode/jbnc.git/commitdiff
Update bouncer.js
authorMadriix <redacted>
Sat, 3 Oct 2020 22:03:34 +0000 (00:03 +0200)
committerMadriix <redacted>
Sat, 3 Oct 2020 22:03:34 +0000 (00:03 +0200)
Fixed this error:

TypeError: Cannot read property 'write' of undefined
    at TLSSocket.<anonymous> (/home/debian/node/jbnc/bouncer.js:312:42)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at TLSSocket.Readable.push (_stream_readable.js:212:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)
# Serious problem (uncaughtException) - this should not happen but the JBNC is still running. TypeError: Cannot read property 'write' of undefined

bouncer.js

index 400e69aef99aebe3bd51e441879f17f8750b790e..eb50797452c9015b750c8b70b7463db7532ad8ba 100644 (file)
@@ -51,9 +51,9 @@ process.on('SIGHUP',function() {
   BOUNCER_ADMIN=config.bouncerAdmin?config.bouncerAdmin:'';
 });
 
-// Prevent BNC from crashing for all other users when an error is caused by a user (with log error)
+// Prevent BNC from crashing for all other users when an error is caused by a user (with log error and time)
 process.on('uncaughtException', (err, origin) => {
-   console.error(`# Serious problem (${origin}) - this should not happen but the JBNC is still running. ${err.stack}`);
+  console.error(`${parseInt(Number(new Date()) / 1000)} # Serious problem (${origin}) - this should not happen but the JBNC is still running. ${err.stack}`);
 });
 
 
@@ -308,7 +308,7 @@ server = doServer(tlsOptions,function(socket) {
                 if(this.lastping == command[1]) {
                   this.lastping='';
                 }
-                else {
+                else if(this.hash && connections[this.hash]) {
                   connections[this.hash].write("PONG "+command[1]+"\n");
                 }
               }