@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.mjs CHANGED
@@ -92,7 +92,8 @@ var TaskRunErrorCodes = {
92
92
  TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE: "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE",
93
93
  TASK_RUN_CANCELLED: "TASK_RUN_CANCELLED",
94
94
  TASK_OUTPUT_ERROR: "TASK_OUTPUT_ERROR",
95
- HANDLE_ERROR_ERROR: "HANDLE_ERROR_ERROR"
95
+ HANDLE_ERROR_ERROR: "HANDLE_ERROR_ERROR",
96
+ GRACEFUL_EXIT_TIMEOUT: "GRACEFUL_EXIT_TIMEOUT"
96
97
  };
97
98
  var TaskRunInternalError = z.object({
98
99
  type: z.literal("INTERNAL_ERROR"),
@@ -106,7 +107,8 @@ var TaskRunInternalError = z.object({
106
107
  "TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE",
107
108
  "TASK_RUN_CANCELLED",
108
109
  "TASK_OUTPUT_ERROR",
109
- "HANDLE_ERROR_ERROR"
110
+ "HANDLE_ERROR_ERROR",
111
+ "GRACEFUL_EXIT_TIMEOUT"
110
112
  ]),
111
113
  message: z.string().optional()
112
114
  });
@@ -3699,6 +3701,17 @@ function formatDurationInDays(milliseconds) {
3699
3701
  return duration;
3700
3702
  }
3701
3703
  __name(formatDurationInDays, "formatDurationInDays");
3704
+ async function unboundedTimeout(delay = 0, value, options) {
3705
+ const maxDelay = 2147483647;
3706
+ const fullTimeouts = Math.floor(delay / maxDelay);
3707
+ const remainingDelay = delay % maxDelay;
3708
+ let lastTimeoutResult = await setTimeout$1(remainingDelay, value, options);
3709
+ for (let i = 0; i < fullTimeouts; i++) {
3710
+ lastTimeoutResult = await setTimeout$1(maxDelay, value, options);
3711
+ }
3712
+ return lastTimeoutResult;
3713
+ }
3714
+ __name(unboundedTimeout, "unboundedTimeout");
3702
3715
 
3703
3716
  // src/v3/runtime/devRuntimeManager.ts
3704
3717
  var _DevRuntimeManager = class _DevRuntimeManager {
@@ -3710,14 +3723,10 @@ var _DevRuntimeManager = class _DevRuntimeManager {
3710
3723
  disable() {
3711
3724
  }
3712
3725
  async waitForDuration(ms) {
3713
- return new Promise((resolve) => {
3714
- setTimeout(resolve, ms);
3715
- });
3726
+ await unboundedTimeout(ms);
3716
3727
  }
3717
3728
  async waitUntil(date) {
3718
- return new Promise((resolve) => {
3719
- setTimeout(resolve, date.getTime() - Date.now());
3720
- });
3729
+ return this.waitForDuration(date.getTime() - Date.now());
3721
3730
  }
3722
3731
  async waitForTask(params) {
3723
3732
  const pendingCompletion = this._pendingCompletionNotifications.get(params.id);
@@ -3780,6 +3789,8 @@ var _DevRuntimeManager = class _DevRuntimeManager {
3780
3789
  };
3781
3790
  __name(_DevRuntimeManager, "DevRuntimeManager");
3782
3791
  var DevRuntimeManager = _DevRuntimeManager;
3792
+
3793
+ // src/v3/runtime/prodRuntimeManager.ts
3783
3794
  var _ProdRuntimeManager = class _ProdRuntimeManager {
3784
3795
  constructor(ipc, options = {}) {
3785
3796
  this.ipc = ipc;
@@ -3791,7 +3802,7 @@ var _ProdRuntimeManager = class _ProdRuntimeManager {
3791
3802
  }
3792
3803
  async waitForDuration(ms) {
3793
3804
  const now = Date.now();
3794
- const resolveAfterDuration = setTimeout$1(ms, "duration");
3805
+ const resolveAfterDuration = unboundedTimeout(ms, "duration");
3795
3806
  if (ms <= this.waitThresholdInMs) {
3796
3807
  await resolveAfterDuration;
3797
3808
  return;