浏览代码

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

Kristian Vos 5 年之前
父节点
当前提交
b3f467259f
共有 1 个文件被更改,包括 4 次插入0 次删除
  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'}); }