From 7002e5a6c1a249f26854a9f218b8440e22d9dfdf Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sat, 4 Jul 2026 15:17:56 +0100 Subject: [PATCH] Enhance callback handling in SocketUser class to ensure callback is a function before invocation, preventing potential runtime errors. --- src/socket/socketuser.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/socket/socketuser.js b/src/socket/socketuser.js index 28efb8b..b63392d 100644 --- a/src/socket/socketuser.js +++ b/src/socket/socketuser.js @@ -174,7 +174,9 @@ export class SocketUser { data.objectType, data.filter ); - callback({ success: true }); + if (typeof callback === 'function') { + callback({ success: true }); + } } async handleSubscribeToObjectUpdateEvent(data, callback) { @@ -182,7 +184,9 @@ export class SocketUser { data._id, data.objectType ); - callback(result); + if (typeof callback === 'function') { + callback(result); + } } async handleSubscribeToObjectEventEvent(data) {