@io-orkes/conductor-javascript 1.2.0-rc.5 → 1.2.0-rc.7

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.mjs CHANGED
@@ -2210,9 +2210,9 @@ var Poller = class {
2210
2210
  /**
2211
2211
  * Stops Polling for work
2212
2212
  */
2213
- this.stopPolling = () => {
2213
+ this.stopPolling = async () => {
2214
+ await Promise.all(this.concurrentCalls.map((call) => call.stop()));
2214
2215
  this.polling = false;
2215
- this.concurrentCalls.forEach((call) => call.stop());
2216
2216
  };
2217
2217
  this.poll = async () => {
2218
2218
  if (!this.polling) {
@@ -2229,17 +2229,18 @@ var Poller = class {
2229
2229
  while (poll) {
2230
2230
  await this.pollFunction();
2231
2231
  await new Promise(
2232
- (r) => timeout = setTimeout(() => r(true), this.options.pollInterval)
2232
+ (r) => poll ? timeout = setTimeout(() => r(true), this.options.pollInterval) : r(true)
2233
2233
  );
2234
2234
  }
2235
2235
  };
2236
2236
  return {
2237
2237
  promise: pollingCall(),
2238
- stop: () => {
2238
+ stop: () => new Promise((r) => {
2239
2239
  clearTimeout(timeout);
2240
2240
  poll = false;
2241
2241
  this.logger.debug("stopping single poll call");
2242
- }
2242
+ r(true);
2243
+ })
2243
2244
  };
2244
2245
  };
2245
2246
  this.pollFunction = pollFunction;
@@ -2302,8 +2303,8 @@ var TaskRunner = class {
2302
2303
  /**
2303
2304
  * Stops Polling for work
2304
2305
  */
2305
- this.stopPolling = () => {
2306
- this.poller.stopPolling();
2306
+ this.stopPolling = async () => {
2307
+ await this.poller.stopPolling();
2307
2308
  };
2308
2309
  this.pollAndExecute = async () => {
2309
2310
  try {
@@ -2469,9 +2470,11 @@ var TaskManager = class {
2469
2470
  /**
2470
2471
  * Stops polling for tasks
2471
2472
  */
2472
- this.stopPolling = () => {
2473
+ this.stopPolling = async () => {
2473
2474
  for (const taskType in this.tasks) {
2474
- this.tasks[taskType].forEach((runner) => runner.stopPolling());
2475
+ await Promise.all(
2476
+ this.tasks[taskType].map((runner) => runner.stopPolling())
2477
+ );
2475
2478
  this.tasks[taskType] = [];
2476
2479
  }
2477
2480
  this.polling = false;