Skip to content

Commit 9bba3cf

Browse files
committed
wrap the remaining handlers in try catch
1 parent aad66a2 commit 9bba3cf

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

apps/coordinator/src/index.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,11 @@ class TaskCoordinator {
536536
socket.on("TEST", (message, callback) => {
537537
logger.log("Handling TEST", { eventName: "TEST", ...getSocketMetadata(), ...message });
538538

539-
callback();
539+
try {
540+
callback();
541+
} catch (error) {
542+
logger.error("TEST error", { error });
543+
}
540544
});
541545

542546
// Deprecated: Only workers without support for lazy attempts use this
@@ -1275,7 +1279,11 @@ class TaskCoordinator {
12751279

12761280
log.log("Handling UNRECOVERABLE_ERROR");
12771281

1278-
await crashRun(message.error);
1282+
try {
1283+
await crashRun(message.error);
1284+
} catch (error) {
1285+
log.error("UNRECOVERABLE_ERROR error", { error });
1286+
}
12791287
});
12801288

12811289
socket.on("SET_STATE", async (message) => {
@@ -1287,20 +1295,28 @@ class TaskCoordinator {
12871295

12881296
log.log("Handling SET_STATE");
12891297

1290-
if (message.attemptFriendlyId) {
1291-
updateAttemptFriendlyId(message.attemptFriendlyId);
1292-
}
1298+
try {
1299+
if (message.attemptFriendlyId) {
1300+
updateAttemptFriendlyId(message.attemptFriendlyId);
1301+
}
12931302

1294-
if (message.attemptNumber) {
1295-
updateAttemptNumber(message.attemptNumber);
1303+
if (message.attemptNumber) {
1304+
updateAttemptNumber(message.attemptNumber);
1305+
}
1306+
} catch (error) {
1307+
log.error("SET_STATE error", { error });
12961308
}
12971309
});
12981310
},
12991311
onDisconnect: async (socket, handler, sender, logger) => {
1300-
this.#platformSocket?.send("LOG", {
1301-
metadata: socket.data,
1302-
text: "disconnect",
1303-
});
1312+
try {
1313+
this.#platformSocket?.send("LOG", {
1314+
metadata: socket.data,
1315+
text: "disconnect",
1316+
});
1317+
} catch (error) {
1318+
logger.error("onDisconnect error", { error });
1319+
}
13041320
},
13051321
handlers: {
13061322
TASK_HEARTBEAT: async (message) => {

0 commit comments

Comments
 (0)