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);
});
}