Problem with socket in plugin after 1.12.2 -> 1.13.0 upgrade
-
Hello !
I'm trying to upgrade my nodebb 1.12.2 forum to 1.13.0 and I have after upgrade/build/start a bug with one of my plugins (which worked very well on 1.12.2).
Error message is :
2019-11-20T16:17:00.664Z [5678/15806] - error: uncaughtException: callback is not a function TypeError: callback is not a function at /home/yannick/MPstarClem/Developpement/nodebb/node_modules/nodebb-widget-online-users-YA/index.js:324:3
When I look in my plugin code, there is a callback call at the line number 324. A console.log(callback) just before this line gives {} which is really strange (obviously, it's not a function...).
Here is a simplified code to show how I get the problem... On the client side, there is a function which is called containing this :
if (socket.connected) { socket.emit('plugins.onlineUsers.getOnlineUsers', function (err, data) { console.log('Just a try'); } ); }
This function calls a getOnlineUsers function on server side which contains this :
socketPlugins.onlineUsers.getOnlineUsers = function(socket, callback) { console.log(callback); // Problem since nodebb 1.13.0 : callback is already {} here !! UpdateUsersOnline(socket.uid, callback); // This function doesn't work because callback is not a function... This gives the error... };
I can't find what have changed in nodebb 1.13.0 since 1.12.2 that makes this problem (I saw nothing relevant in breaking changes).
Any help ? Thanks !
-
@baris Ok, I will have to change this on many plugins (I hope it will be not too difficult ; I never used async/await but if you talk about this to me, it may be greater than async module ).
Edit : Mmmm, I tried your suggestion but I get again the error
error: uncaughtException: callback is not a function TypeError: callback is not a function
with it. I will have to look closer to functions arguments when going from async module to async/await...