@cadenza.io/service 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -328,6 +328,7 @@ var ServiceRegistry = class _ServiceRegistry {
328
328
  deleted
329
329
  } = serviceInstance;
330
330
  if (uuid4 === this.serviceInstanceId) return;
331
+ console.log("service instance", serviceName, uuid4, address, deleted);
331
332
  if (deleted) {
332
333
  this.instances.get(serviceName)?.splice(
333
334
  this.instances.get(serviceName)?.findIndex((i) => i.uuid === uuid4) ?? -1,
@@ -407,6 +408,7 @@ var ServiceRegistry = class _ServiceRegistry {
407
408
  this.handleGlobalSignalRegistrationTask = CadenzaService.createMetaTask(
408
409
  "Handle global Signal Registration",
409
410
  (ctx) => {
411
+ console.log("Handling global signal registration...");
410
412
  const { signalToTaskMaps } = ctx;
411
413
  const sortedSignalToTaskMap = signalToTaskMaps.sort(
412
414
  (a, b) => {
@@ -547,6 +549,10 @@ var ServiceRegistry = class _ServiceRegistry {
547
549
  ctx.joinedContexts.forEach((ctx2) => {
548
550
  joinedContext = { ...joinedContext, ...ctx2 };
549
551
  });
552
+ console.log(
553
+ "merging contexts of full sync...",
554
+ joinedContext.keys().join(", ")
555
+ );
550
556
  return joinedContext;
551
557
  }
552
558
  ).then(this.handleGlobalSignalRegistrationTask);
@@ -1137,6 +1143,7 @@ var RestController = class _RestController {
1137
1143
  });
1138
1144
  return;
1139
1145
  }
1146
+ console.log("Service inserted...");
1140
1147
  const app = (0, import_express.default)();
1141
1148
  app.use(import_body_parser.default.json());
1142
1149
  switch (ctx.__securityProfile) {
@@ -1509,15 +1516,20 @@ var RestController = class _RestController {
1509
1516
  }
1510
1517
  let resultContext;
1511
1518
  try {
1512
- const response = await (0, import_node_fetch.default)(`${URL}/delegation`, {
1513
- headers: {
1514
- "Content-Type": "application/json"
1519
+ const response = await this.fetchDataWithTimeout(
1520
+ `${URL}/delegation`,
1521
+ {
1522
+ headers: {
1523
+ "Content-Type": "application/json"
1524
+ },
1525
+ method: "POST",
1526
+ body: JSON.stringify(ctx2)
1515
1527
  },
1516
- method: "POST",
1517
- body: JSON.stringify(ctx2)
1518
- });
1528
+ 3e4
1529
+ );
1519
1530
  resultContext = await response.json();
1520
1531
  } catch (e) {
1532
+ console.error("Error in delegation", e);
1521
1533
  resultContext = {
1522
1534
  __error: `Error: ${e}`,
1523
1535
  errored: true,
@@ -1560,6 +1572,7 @@ var RestController = class _RestController {
1560
1572
  emit(`meta.fetch.transmitted:${ctx2.__routineExecId}`, response);
1561
1573
  }
1562
1574
  } catch (e) {
1575
+ console.error("Error in transmission", e);
1563
1576
  response = {
1564
1577
  __error: `Error: ${e}`,
1565
1578
  errored: true,
@@ -1998,6 +2011,7 @@ var SocketController = class _SocketController {
1998
2011
  CadenzaService.emit("meta.socket_client.status_received", status);
1999
2012
  });
2000
2013
  socket.on("connect_error", (err) => {
2014
+ handshake = false;
2001
2015
  CadenzaService.log(
2002
2016
  "Socket connect error",
2003
2017
  { error: err.message, serviceName, socketId: socket.id, URL },
@@ -2016,6 +2030,7 @@ var SocketController = class _SocketController {
2016
2030
  });
2017
2031
  });
2018
2032
  socket.on("reconnect_error", (err) => {
2033
+ handshake = false;
2019
2034
  CadenzaService.log(
2020
2035
  "Socket reconnect failed.",
2021
2036
  { error: err.message, serviceName, URL, socketId: socket.id },
@@ -2135,6 +2150,7 @@ var SocketController = class _SocketController {
2135
2150
  CadenzaService.createEphemeralMetaTask(
2136
2151
  `Shutdown SocketClient ${URL}`,
2137
2152
  (ctx2, emit) => {
2153
+ handshake = false;
2138
2154
  CadenzaService.log("Shutting down socket client", { URL, serviceName });
2139
2155
  socket?.close();
2140
2156
  handshakeTask.destroy();