Node.js based forum software built for the modern web
feat: awaitable websockets (#7645)
Julian Lamaee47b299a73
diff --git a/src/socket.io/index.js b/src/socket.io/index.jsindex 91d660317d..1e101953ba 100644--- a/src/socket.io/index.js+++ b/src/socket.io/index.js@@ -131,6 +131,7 @@ function onMessage(socket, payload) {return socket.disconnect();}+ var cbCalled = false;async.waterfall([function (next) {checkMaintenance(socket, next);@@ -146,9 +147,19 @@ function onMessage(socket, payload) {}},function (next) {- methodToCall(socket, params, next);+ const returned = methodToCall(socket, params, next);+ if (returned && typeof returned.then === 'function') {+ returned.then((payload) => {+ next(null, payload);+ }, next);+ }},], function (err, result) {+ if (cbCalled) {+ return;+ }++ cbCalled = true;callback(err ? { message: err.message } : null, result);});}