@hatchet-dev/typescript-sdk 1.10.7 → 1.10.8

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.
@@ -187,7 +187,7 @@ class V0Worker {
187
187
  return step(context);
188
188
  });
189
189
  const success = (result) => __awaiter(this, void 0, void 0, function* () {
190
- this.logger.info(`Step run ${action.stepRunId} succeeded`);
190
+ this.logger.info(`Task run ${action.stepRunId} succeeded`);
191
191
  try {
192
192
  // Send the action event to the dispatcher
193
193
  const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, false, result || null, action.retryCount);
@@ -212,7 +212,7 @@ class V0Worker {
212
212
  }
213
213
  });
214
214
  const failure = (error) => __awaiter(this, void 0, void 0, function* () {
215
- this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
215
+ this.logger.error(`Task run ${action.stepRunId} failed: ${error.message}`);
216
216
  if (error.stack) {
217
217
  this.logger.error(error.stack);
218
218
  }
@@ -255,7 +255,14 @@ class V0Worker {
255
255
  yield future.promise;
256
256
  }
257
257
  catch (e) {
258
- this.logger.error('Could not wait for step run to finish: ', e);
258
+ const message = (e === null || e === void 0 ? void 0 : e.message) || String(e);
259
+ if (message.includes('Cancelled')) {
260
+ this.logger.debug(`Task run ${action.stepRunId} was cancelled`);
261
+ }
262
+ else {
263
+ this.logger.error(`Could not wait for task run ${action.stepRunId} to finish. ` +
264
+ `See https://docs.hatchet.run/home/cancellation for best practices on handling cancellation: `, e);
265
+ }
259
266
  }
260
267
  }
261
268
  catch (e) {
@@ -284,7 +291,7 @@ class V0Worker {
284
291
  return step(context);
285
292
  });
286
293
  const success = (result) => {
287
- this.logger.info(`Step run ${action.stepRunId} succeeded`);
294
+ this.logger.info(`Task run ${action.stepRunId} succeeded`);
288
295
  try {
289
296
  // Send the action event to the dispatcher
290
297
  const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
@@ -302,7 +309,7 @@ class V0Worker {
302
309
  }
303
310
  };
304
311
  const failure = (error) => {
305
- this.logger.error(`Step run ${key} failed: ${error.message}`);
312
+ this.logger.error(`Task run ${key} failed: ${error.message}`);
306
313
  try {
307
314
  // Send the action event to the dispatcher
308
315
  const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
@@ -366,7 +373,7 @@ class V0Worker {
366
373
  return __awaiter(this, void 0, void 0, function* () {
367
374
  const { stepRunId } = action;
368
375
  try {
369
- this.logger.info(`Cancelling step run ${action.stepRunId}`);
376
+ this.logger.info(`Cancelling task run ${action.stepRunId}`);
370
377
  const future = this.futures[(0, action_listener_1.createActionKey)(action)];
371
378
  const context = this.contexts[(0, action_listener_1.createActionKey)(action)];
372
379
  if (context && context.controller) {
@@ -374,14 +381,15 @@ class V0Worker {
374
381
  }
375
382
  if (future) {
376
383
  future.promise.catch(() => {
377
- this.logger.info(`Cancelled step run ${action.stepRunId}`);
384
+ this.logger.info(`Cancelled task run ${action.stepRunId}`);
378
385
  });
379
386
  future.cancel('Cancelled by worker');
380
387
  yield future.promise;
381
388
  }
382
389
  }
383
390
  catch (e) {
384
- this.logger.error('Could not cancel step run: ', e);
391
+ // Expected: the promise rejects when cancelled
392
+ this.logger.debug(`Task run ${stepRunId} cancellation completed`);
385
393
  }
386
394
  finally {
387
395
  delete this.futures[(0, action_listener_1.createActionKey)(action)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.10.7",
3
+ "version": "1.10.8",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -423,7 +423,7 @@ class V1Worker {
423
423
  if (context.cancelled) {
424
424
  return;
425
425
  }
426
- this.logger.info(`Step run ${action.stepRunId} succeeded`);
426
+ this.logger.info(`Task run ${action.stepRunId} succeeded`);
427
427
  // Send the action event to the dispatcher
428
428
  const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, false, result || null, action.retryCount);
429
429
  yield this.client._v0.dispatcher.sendStepActionEvent(event);
@@ -452,7 +452,7 @@ class V1Worker {
452
452
  if (context.cancelled) {
453
453
  return;
454
454
  }
455
- this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
455
+ this.logger.error(`Task run ${action.stepRunId} failed: ${error.message}`);
456
456
  if (error.stack) {
457
457
  this.logger.error(error.stack);
458
458
  }
@@ -493,7 +493,14 @@ class V1Worker {
493
493
  yield future.promise;
494
494
  }
495
495
  catch (e) {
496
- this.logger.error('Could not wait for step run to finish: ', e);
496
+ const message = (e === null || e === void 0 ? void 0 : e.message) || String(e);
497
+ if (message.includes('Cancelled')) {
498
+ this.logger.debug(`Task run ${action.stepRunId} was cancelled`);
499
+ }
500
+ else {
501
+ this.logger.error(`Could not wait for task run ${action.stepRunId} to finish. ` +
502
+ `See https://docs.hatchet.run/home/cancellation for best practices on handling cancellation: `, e);
503
+ }
497
504
  }
498
505
  }
499
506
  catch (e) {
@@ -523,7 +530,7 @@ class V1Worker {
523
530
  return step(context);
524
531
  });
525
532
  const success = (result) => {
526
- this.logger.info(`Step run ${action.stepRunId} succeeded`);
533
+ this.logger.info(`Task run ${action.stepRunId} succeeded`);
527
534
  try {
528
535
  // Send the action event to the dispatcher
529
536
  const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
@@ -541,7 +548,7 @@ class V1Worker {
541
548
  }
542
549
  };
543
550
  const failure = (error) => {
544
- this.logger.error(`Step run ${key} failed: ${error.message}`);
551
+ this.logger.error(`Task run ${key} failed: ${error.message}`);
545
552
  try {
546
553
  // Send the action event to the dispatcher
547
554
  const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
@@ -605,7 +612,7 @@ class V1Worker {
605
612
  return __awaiter(this, void 0, void 0, function* () {
606
613
  const { stepRunId } = action;
607
614
  try {
608
- this.logger.info(`Cancelling step run ${action.stepRunId}`);
615
+ this.logger.info(`Cancelling task run ${action.stepRunId}`);
609
616
  const future = this.futures[stepRunId];
610
617
  const context = this.contexts[stepRunId];
611
618
  if (context && context.abortController) {
@@ -613,14 +620,15 @@ class V1Worker {
613
620
  }
614
621
  if (future) {
615
622
  future.promise.catch(() => {
616
- this.logger.info(`Cancelled step run ${action.stepRunId}`);
623
+ this.logger.info(`Cancelled task run ${action.stepRunId}`);
617
624
  });
618
625
  future.cancel('Cancelled by worker');
619
626
  yield future.promise;
620
627
  }
621
628
  }
622
629
  catch (e) {
623
- this.logger.error('Could not cancel step run: ', e);
630
+ // Expected: the promise rejects when cancelled
631
+ this.logger.debug(`Task run ${stepRunId} cancellation completed`);
624
632
  }
625
633
  finally {
626
634
  delete this.futures[stepRunId];
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.10.7";
1
+ export declare const HATCHET_VERSION = "1.10.8";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HATCHET_VERSION = void 0;
4
- exports.HATCHET_VERSION = '1.10.7';
4
+ exports.HATCHET_VERSION = '1.10.8';