nodebb crash when read chat message


  • Gamers

    nodebb crash when read chat message, error log as below:
    20/5 02:48 [246] - error: TypeError: Cannot read property 'fromuid' of undefined
    at /opt/nodebb/src/messaging.js:146:34
    at /opt/nodebb/node_modules/async/lib/async.js:249:17
    at /opt/nodebb/node_modules/async/lib/async.js:125:13


  • Gamers

    this error due to the dirty data in database,
    I am using mongodb, but not clear how to clean up the chat message


  • Gamers

    code changes to avoid the crash, but peoples with dirty data can not see chat message from each other.

    			function(messages, next) {
    				async.map(messages, function(message, next) {
    			if(typeof message === 'undefined') {                               //changes
    				winston.error('message is undefined.');
    			}else {
    				winston.info('message=`' + JSON.stringify(message) );
    
    					var self = parseInt(message.fromuid, 10) === parseInt(fromuid, 10);
    					message.fromUser = self ? userData[0] : userData[1];
    					message.toUser = self ? userData[1] : userData[0];
    					message.timestampISO = utils.toISOString(message.timestamp);
    					message.self = self ? 1 : 0;
    					message.newSet = false;
    
    					Messaging.parse(message.content, message.fromuid, fromuid, userData[1], userData[0], isNew, function(result) {
    						message.content = result;
    						next(null, message);
    					});
    			}

  • Gamers

    problem solved with the latest fix, thanks~😄


 

| |