Skip to content

Commit 86faebe

Browse files
committed
refactor(hub): refactored codes - to match the passing values on both sides - the client & server
1 parent ecb9a41 commit 86faebe

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/hub.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ io.on("connection", (socket) => {
102102
id: payload.id,
103103
// error: `Service "${targetService}" not found`, // This was causing a crash in the client response handler because it was expecting a "data" key
104104
// data: { error: `Service "${targetService}" not found` }, // This is the correct way to handle the error - return a data object with an "error" key
105-
data: {
105+
response: {
106106
error: new CustomError(
107107
"TARGET_SERVICE_NOT_FOUND",
108108
`Service "${targetService}" not found`,
@@ -130,7 +130,7 @@ io.on("connection", (socket) => {
130130

131131
if (requestSenderSockerID) {
132132
// Emit the response only to the requesting client
133-
io.to(requestSenderSockerID).emit("response", { id, data: response });
133+
io.to(requestSenderSockerID).emit("response", { id, response });
134134
pendingRequests.delete(id); // Clean up
135135
} else {
136136
logger.warn(`No pending request found for ID ${id}`);

0 commit comments

Comments
 (0)