@trigger.dev/core 3.0.0-beta.13 → 3.0.0-beta.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/v3/index.js CHANGED
@@ -100,7 +100,8 @@ var TaskRunErrorCodes = {
100
100
  TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE: "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE",
101
101
  TASK_RUN_CANCELLED: "TASK_RUN_CANCELLED",
102
102
  TASK_OUTPUT_ERROR: "TASK_OUTPUT_ERROR",
103
- HANDLE_ERROR_ERROR: "HANDLE_ERROR_ERROR"
103
+ HANDLE_ERROR_ERROR: "HANDLE_ERROR_ERROR",
104
+ GRACEFUL_EXIT_TIMEOUT: "GRACEFUL_EXIT_TIMEOUT"
104
105
  };
105
106
  var TaskRunInternalError = zod.z.object({
106
107
  type: zod.z.literal("INTERNAL_ERROR"),
@@ -114,7 +115,8 @@ var TaskRunInternalError = zod.z.object({
114
115
  "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE",
115
116
  "TASK_RUN_CANCELLED",
116
117
  "TASK_OUTPUT_ERROR",
117
- "HANDLE_ERROR_ERROR"
118
+ "HANDLE_ERROR_ERROR",
119
+ "GRACEFUL_EXIT_TIMEOUT"
118
120
  ]),
119
121
  message: zod.z.string().optional()
120
122
  });
@@ -3707,6 +3709,17 @@ function formatDurationInDays(milliseconds) {
3707
3709
  return duration;
3708
3710
  }
3709
3711
  __name(formatDurationInDays, "formatDurationInDays");
3712
+ async function unboundedTimeout(delay = 0, value, options) {
3713
+ const maxDelay = 2147483647;
3714
+ const fullTimeouts = Math.floor(delay / maxDelay);
3715
+ const remainingDelay = delay % maxDelay;
3716
+ let lastTimeoutResult = await promises.setTimeout(remainingDelay, value, options);
3717
+ for (let i = 0; i < fullTimeouts; i++) {
3718
+ lastTimeoutResult = await promises.setTimeout(maxDelay, value, options);
3719
+ }
3720
+ return lastTimeoutResult;
3721
+ }
3722
+ __name(unboundedTimeout, "unboundedTimeout");
3710
3723
 
3711
3724
  // src/v3/runtime/devRuntimeManager.ts
3712
3725
  var _DevRuntimeManager = class _DevRuntimeManager {
@@ -3718,14 +3731,10 @@ var _DevRuntimeManager = class _DevRuntimeManager {
3718
3731
  disable() {
3719
3732
  }
3720
3733
  async waitForDuration(ms) {
3721
- return new Promise((resolve) => {
3722
- setTimeout(resolve, ms);
3723
- });
3734
+ await unboundedTimeout(ms);
3724
3735
  }
3725
3736
  async waitUntil(date) {
3726
- return new Promise((resolve) => {
3727
- setTimeout(resolve, date.getTime() - Date.now());
3728
- });
3737
+ return this.waitForDuration(date.getTime() - Date.now());
3729
3738
  }
3730
3739
  async waitForTask(params) {
3731
3740
  const pendingCompletion = this._pendingCompletionNotifications.get(params.id);
@@ -3788,6 +3797,8 @@ var _DevRuntimeManager = class _DevRuntimeManager {
3788
3797
  };
3789
3798
  __name(_DevRuntimeManager, "DevRuntimeManager");
3790
3799
  var DevRuntimeManager = _DevRuntimeManager;
3800
+
3801
+ // src/v3/runtime/prodRuntimeManager.ts
3791
3802
  var _ProdRuntimeManager = class _ProdRuntimeManager {
3792
3803
  constructor(ipc, options = {}) {
3793
3804
  this.ipc = ipc;
@@ -3799,7 +3810,7 @@ var _ProdRuntimeManager = class _ProdRuntimeManager {
3799
3810
  }
3800
3811
  async waitForDuration(ms) {
3801
3812
  const now = Date.now();
3802
- const resolveAfterDuration = promises.setTimeout(ms, "duration");
3813
+ const resolveAfterDuration = unboundedTimeout(ms, "duration");
3803
3814
  if (ms <= this.waitThresholdInMs) {
3804
3815
  await resolveAfterDuration;
3805
3816
  return;