@cadenza.io/service 2.3.13 → 2.3.14

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
@@ -178,6 +178,7 @@ var DeputyTask = class extends import_core.Task {
178
178
  const ctx = context.getContext();
179
179
  const metadata = context.getMetadata();
180
180
  const deputyContext = {
181
+ __timeout: this.timeout,
181
182
  __localTaskName: this.name,
182
183
  __localTaskVersion: this.version,
183
184
  __localServiceName: CadenzaService.serviceRegistry.serviceName,
@@ -560,7 +561,7 @@ var ServiceRegistry = class _ServiceRegistry {
560
561
  );
561
562
  return joinedContext;
562
563
  }
563
- ).then(this.handleGlobalSignalRegistrationTask);
564
+ ).emits("meta.service_registry.initial_sync_complete").then(this.handleGlobalSignalRegistrationTask);
564
565
  this.fullSyncTask = CadenzaService.createMetaRoutine("Full sync", [
565
566
  CadenzaService.createTask("Confirm full sync", () => {
566
567
  console.log("Confirming full sync...");
@@ -1950,7 +1951,7 @@ var SocketController = class _SocketController {
1950
1951
  transports: ["websocket"],
1951
1952
  autoConnect: false
1952
1953
  });
1953
- emitWhenReady = (event, data, timeoutMs = 2e4, ack) => {
1954
+ emitWhenReady = (event, data, timeoutMs = 6e4, ack) => {
1954
1955
  return new Promise((resolve) => {
1955
1956
  const tryEmit = () => {
1956
1957
  if (!socket?.connected) {
@@ -1984,7 +1985,12 @@ var SocketController = class _SocketController {
1984
1985
  if (err) {
1985
1986
  CadenzaService.log(
1986
1987
  "Socket timeout.",
1987
- { error: err.message, socketId: socket?.id, serviceName },
1988
+ {
1989
+ event,
1990
+ error: err.message,
1991
+ socketId: socket?.id,
1992
+ serviceName
1993
+ },
1988
1994
  "warning"
1989
1995
  );
1990
1996
  response = {
@@ -2102,13 +2108,6 @@ var SocketController = class _SocketController {
2102
2108
  "warning"
2103
2109
  );
2104
2110
  }
2105
- if (result.errored) {
2106
- errorCount++;
2107
- if (errorCount > ERROR_LIMIT) {
2108
- console.error("Too many errors, closing socket", URL);
2109
- emit(`meta.socket_shutdown_requested:${fetchId}`, {});
2110
- }
2111
- }
2112
2111
  }
2113
2112
  );
2114
2113
  },
@@ -2129,7 +2128,7 @@ var SocketController = class _SocketController {
2129
2128
  emitWhenReady?.(
2130
2129
  "delegation",
2131
2130
  ctx2,
2132
- 2e4,
2131
+ ctx2.__timeout ?? 6e4,
2133
2132
  (resultContext) => {
2134
2133
  const requestDuration = Date.now() - requestSentAt;
2135
2134
  const metadata = resultContext.__metadata;
@@ -2149,13 +2148,6 @@ var SocketController = class _SocketController {
2149
2148
  }
2150
2149
  );
2151
2150
  pendingDelegationIds.delete(ctx2.__metadata.__deputyExecId);
2152
- if (resultContext.errored) {
2153
- errorCount++;
2154
- if (errorCount > ERROR_LIMIT) {
2155
- console.error("Too many errors, closing socket", URL);
2156
- emit(`meta.socket_shutdown_requested:${fetchId}`, {});
2157
- }
2158
- }
2159
2151
  resolve(resultContext);
2160
2152
  }
2161
2153
  );
@@ -2182,13 +2174,6 @@ var SocketController = class _SocketController {
2182
2174
  response
2183
2175
  );
2184
2176
  }
2185
- if (response.errored) {
2186
- errorCount++;
2187
- if (errorCount > ERROR_LIMIT) {
2188
- console.error("Too many errors, closing socket", URL);
2189
- emit(`meta.socket_shutdown_requested:${fetchId}`, {});
2190
- }
2191
- }
2192
2177
  resolve(response);
2193
2178
  });
2194
2179
  });
@@ -3831,14 +3816,14 @@ var GraphSyncController = class _GraphSyncController {
3831
3816
  }
3832
3817
  }
3833
3818
  },
3834
- { concurrency: 50 }
3819
+ { concurrency: 30 }
3835
3820
  ) : CadenzaService.get("dbInsertRoutine"))?.then(
3836
3821
  CadenzaService.createMetaTask("Register routine", (ctx) => {
3837
3822
  if (!ctx.__syncing) {
3838
3823
  return;
3839
3824
  }
3840
3825
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
3841
- delayMs: 2e3
3826
+ delayMs: 3e3
3842
3827
  });
3843
3828
  CadenzaService.getRoutine(ctx.__routineName).registered = true;
3844
3829
  return true;
@@ -3856,7 +3841,7 @@ var GraphSyncController = class _GraphSyncController {
3856
3841
  const { routines } = ctx;
3857
3842
  if (!routines) return;
3858
3843
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
3859
- delayMs: 2e3
3844
+ delayMs: 3e3
3860
3845
  });
3861
3846
  for (const routine of routines) {
3862
3847
  for (const task of routine.tasks) {
@@ -3900,7 +3885,7 @@ var GraphSyncController = class _GraphSyncController {
3900
3885
  }
3901
3886
  }
3902
3887
  },
3903
- { concurrency: 50 }
3888
+ { concurrency: 30 }
3904
3889
  ) : CadenzaService.get("dbInsertTaskToRoutineMap"))?.then(
3905
3890
  CadenzaService.createMetaTask("Register routine task", (ctx) => {
3906
3891
  if (!ctx.__syncing) {
@@ -3919,7 +3904,7 @@ var GraphSyncController = class _GraphSyncController {
3919
3904
  "Split signals for registration",
3920
3905
  function* (ctx) {
3921
3906
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
3922
- delayMs: 2e3
3907
+ delayMs: 3e3
3923
3908
  });
3924
3909
  const { signals } = ctx;
3925
3910
  if (!signals) return;
@@ -3951,14 +3936,14 @@ var GraphSyncController = class _GraphSyncController {
3951
3936
  }
3952
3937
  }
3953
3938
  },
3954
- { concurrency: 50 }
3939
+ { concurrency: 30 }
3955
3940
  ) : CadenzaService.get("dbInsertSignalRegistry"))?.then(
3956
3941
  CadenzaService.createMetaTask("Process signal registration", (ctx) => {
3957
3942
  if (!ctx.__syncing) {
3958
3943
  return;
3959
3944
  }
3960
3945
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
3961
- delayMs: 2e3
3946
+ delayMs: 3e3
3962
3947
  });
3963
3948
  return { signalName: ctx.__signal };
3964
3949
  }).then(
@@ -3974,7 +3959,7 @@ var GraphSyncController = class _GraphSyncController {
3974
3959
  "Split tasks for registration",
3975
3960
  function* (ctx) {
3976
3961
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
3977
- delayMs: 2e3
3962
+ delayMs: 3e3
3978
3963
  });
3979
3964
  const tasks = ctx.tasks;
3980
3965
  for (const task of tasks) {
@@ -4029,14 +4014,14 @@ var GraphSyncController = class _GraphSyncController {
4029
4014
  }
4030
4015
  }
4031
4016
  },
4032
- { concurrency: 50 }
4017
+ { concurrency: 30 }
4033
4018
  ) : CadenzaService.get("dbInsertTask"))?.then(
4034
4019
  CadenzaService.createMetaTask("Record registration", (ctx) => {
4035
4020
  if (!ctx.__syncing) {
4036
4021
  return;
4037
4022
  }
4038
4023
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
4039
- delayMs: 2e3
4024
+ delayMs: 3e3
4040
4025
  });
4041
4026
  CadenzaService.get(ctx.__taskName).registered = true;
4042
4027
  return true;
@@ -4055,7 +4040,7 @@ var GraphSyncController = class _GraphSyncController {
4055
4040
  return;
4056
4041
  }
4057
4042
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
4058
- delayMs: 2e3
4043
+ delayMs: 3e3
4059
4044
  });
4060
4045
  CadenzaService.get(ctx.__taskName)?.registeredSignals.add(ctx.__signal);
4061
4046
  }
@@ -4098,7 +4083,7 @@ var GraphSyncController = class _GraphSyncController {
4098
4083
  }
4099
4084
  }
4100
4085
  },
4101
- { concurrency: 50 }
4086
+ { concurrency: 30 }
4102
4087
  ) : CadenzaService.get("dbInsertSignalToTaskMap"))?.then(registerSignalTask)
4103
4088
  );
4104
4089
  this.registerTaskMapTask = CadenzaService.createMetaTask(
@@ -4106,7 +4091,7 @@ var GraphSyncController = class _GraphSyncController {
4106
4091
  function* (ctx) {
4107
4092
  const task = ctx.task;
4108
4093
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
4109
- delayMs: 2e3
4094
+ delayMs: 3e3
4110
4095
  });
4111
4096
  if (task.hidden || !task.register) return;
4112
4097
  for (const t of task.nextTasks) {
@@ -4145,14 +4130,14 @@ var GraphSyncController = class _GraphSyncController {
4145
4130
  }
4146
4131
  }
4147
4132
  },
4148
- { concurrency: 50 }
4133
+ { concurrency: 30 }
4149
4134
  ) : CadenzaService.get("dbInsertDirectionalTaskGraphMap"))?.then(
4150
4135
  CadenzaService.createMetaTask("Record task map registration", (ctx) => {
4151
4136
  if (!ctx.__syncing) {
4152
4137
  return;
4153
4138
  }
4154
4139
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
4155
- delayMs: 2e3
4140
+ delayMs: 3e3
4156
4141
  });
4157
4142
  CadenzaService.get(ctx.__taskName)?.taskMapRegistration.add(
4158
4143
  ctx.__nextTaskName
@@ -4198,7 +4183,7 @@ var GraphSyncController = class _GraphSyncController {
4198
4183
  }
4199
4184
  }
4200
4185
  },
4201
- { concurrency: 50 }
4186
+ { concurrency: 30 }
4202
4187
  ) : CadenzaService.get("dbInsertDirectionalTaskGraphMap"))?.then(
4203
4188
  CadenzaService.createMetaTask(
4204
4189
  "Record deputy relationship registration",
@@ -4207,14 +4192,17 @@ var GraphSyncController = class _GraphSyncController {
4207
4192
  return;
4208
4193
  }
4209
4194
  CadenzaService.debounce("meta.sync_controller.synced_resource", {
4210
- delayMs: 2e3
4195
+ delayMs: 3e3
4211
4196
  });
4212
4197
  CadenzaService.get(ctx.__taskName).registeredDeputyMap = true;
4213
4198
  }
4214
4199
  )
4215
4200
  )
4216
4201
  );
4217
- CadenzaService.signalBroker.getSignalsTask.clone().doOn("meta.sync_controller.sync_tick", "meta.sync_requested").then(this.splitSignalsTask);
4202
+ CadenzaService.signalBroker.getSignalsTask.clone().doOn(
4203
+ "meta.sync_controller.sync_tick",
4204
+ "meta.service_registry.initial_sync_complete"
4205
+ ).then(this.splitSignalsTask);
4218
4206
  CadenzaService.registry.getAllTasks.clone().doOn("meta.sync_controller.synced_signals").then(this.splitTasksForRegistration);
4219
4207
  CadenzaService.registry.getAllRoutines.clone().doOn("meta.sync_controller.synced_tasks").then(this.splitRoutinesTask);
4220
4208
  CadenzaService.registry.doForEachTask.clone().doOn("meta.sync_controller.synced_tasks").then(
@@ -4250,7 +4238,7 @@ var GraphSyncController = class _GraphSyncController {
4250
4238
  { __syncing: true },
4251
4239
  18e4
4252
4240
  );
4253
- CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 5e3);
4241
+ CadenzaService.schedule("meta.sync_requested", { __syncing: true }, 2e3);
4254
4242
  }
4255
4243
  console.log("Syncing initiated", this.isCadenzaDBReady);
4256
4244
  }