Kaynağa Gözat

feat: when there's no callback provided on a socket.io action, no error is thrown

Kristian Vos 5 yıl önce
ebeveyn
işleme
b3f467259f
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  1. 4 0
      backend/logic/io.js

+ 4 - 0
backend/logic/io.js

@@ -118,6 +118,10 @@ module.exports = class extends coreClass {
 							socket.on(name, async function() {
 								let args = Array.prototype.slice.call(arguments, 0, -1);
 								let cb = arguments[arguments.length - 1];
+								if (typeof cb !== "function")
+									cb = () => {
+										_this.logger.info("IO_MODULE", `There was no callback provided for ${name}.`);
+									}
 
 								try { await _this._validateHook(); } catch { return cb({status: 'failure', message: 'Lockdown'}); }