Skip to content

Commit

Permalink
Check for callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrik Meijer committed Apr 16, 2024
1 parent d5c4cb2 commit 416cb53
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/server/storage/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ function WebSocket(storage, mainLogger, gmeConfig, gmeAuth, workerManager) {
} else {
logger.error(err.stack, '\n', (new Error('Caught by')).stack);
}
callback(err.message);

callback && callback(err.message);
};
}

Expand Down Expand Up @@ -1081,12 +1082,6 @@ function WebSocket(storage, mainLogger, gmeConfig, gmeAuth, workerManager) {
var transformedSelection,
eventData;

function done(err) {
if (callback) {
callback(err ? err.message : undefined);
}
}

try {
if (typeof data.watcherId !== 'string') {
throw new Error('data.watcherId not provided!');
Expand Down Expand Up @@ -1114,9 +1109,9 @@ function WebSocket(storage, mainLogger, gmeConfig, gmeAuth, workerManager) {
socket.broadcast.to(data.docId).emit(CONSTANTS.DOCUMENT_SELECTION, eventData);
}

done();
callback && callback();
} catch (err) {
getErrorHandler(done)(err);
getErrorHandler(callback)(err);
}
});

Expand Down

0 comments on commit 416cb53

Please sign in to comment.