@trigger.dev/sdk 3.0.0-beta.5 → 3.0.0-beta.51

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.d.mts CHANGED
@@ -2670,7 +2670,11 @@ declare class AutoYieldWithCompletedTaskExecutionError {
2670
2670
  timeElapsed: number;
2671
2671
  }, output?: string | undefined);
2672
2672
  }
2673
- type TriggerInternalError = ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError | ResumeWithParallelTaskError;
2673
+ declare class AutoYieldRateLimitError {
2674
+ resetAtTimestamp: number;
2675
+ constructor(resetAtTimestamp: number);
2676
+ }
2677
+ type TriggerInternalError = ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError | AutoYieldRateLimitError | ResumeWithParallelTaskError;
2674
2678
  /** Use this function if you're using a `try/catch` block to catch errors.
2675
2679
  * It checks if a thrown error is a special internal error that you should ignore.
2676
2680
  * If this returns `true` then you must rethrow the error: `throw err;`
package/dist/index.d.ts CHANGED
@@ -2670,7 +2670,11 @@ declare class AutoYieldWithCompletedTaskExecutionError {
2670
2670
  timeElapsed: number;
2671
2671
  }, output?: string | undefined);
2672
2672
  }
2673
- type TriggerInternalError = ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError | ResumeWithParallelTaskError;
2673
+ declare class AutoYieldRateLimitError {
2674
+ resetAtTimestamp: number;
2675
+ constructor(resetAtTimestamp: number);
2676
+ }
2677
+ type TriggerInternalError = ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError | AutoYieldRateLimitError | ResumeWithParallelTaskError;
2674
2678
  /** Use this function if you're using a `try/catch` block to catch errors.
2675
2679
  * It checks if a thrown error is a special internal error that you should ignore.
2676
2680
  * If this returns `true` then you must rethrow the error: `throw err;`
package/dist/index.js CHANGED
@@ -266,7 +266,7 @@ __name(_Job, "Job");
266
266
  var Job = _Job;
267
267
 
268
268
  // package.json
269
- var version = "3.0.0-beta.5";
269
+ var version = "3.0.0-beta.51";
270
270
 
271
271
  // src/errors.ts
272
272
  var _ResumeWithTaskError = class _ResumeWithTaskError {
@@ -326,6 +326,13 @@ var _AutoYieldWithCompletedTaskExecutionError = class _AutoYieldWithCompletedTas
326
326
  };
327
327
  __name(_AutoYieldWithCompletedTaskExecutionError, "AutoYieldWithCompletedTaskExecutionError");
328
328
  var AutoYieldWithCompletedTaskExecutionError = _AutoYieldWithCompletedTaskExecutionError;
329
+ var _AutoYieldRateLimitError = class _AutoYieldRateLimitError {
330
+ constructor(resetAtTimestamp) {
331
+ this.resetAtTimestamp = resetAtTimestamp;
332
+ }
333
+ };
334
+ __name(_AutoYieldRateLimitError, "AutoYieldRateLimitError");
335
+ var AutoYieldRateLimitError = _AutoYieldRateLimitError;
329
336
  var _ParsedPayloadSchemaError = class _ParsedPayloadSchemaError {
330
337
  constructor(schemaErrors) {
331
338
  this.schemaErrors = schemaErrors;
@@ -334,7 +341,7 @@ var _ParsedPayloadSchemaError = class _ParsedPayloadSchemaError {
334
341
  __name(_ParsedPayloadSchemaError, "ParsedPayloadSchemaError");
335
342
  var ParsedPayloadSchemaError = _ParsedPayloadSchemaError;
336
343
  function isTriggerError(err) {
337
- return err instanceof ResumeWithTaskError || err instanceof RetryWithTaskError || err instanceof CanceledWithTaskError || err instanceof YieldExecutionError || err instanceof AutoYieldExecutionError || err instanceof AutoYieldWithCompletedTaskExecutionError || err instanceof ResumeWithParallelTaskError;
344
+ return err instanceof ResumeWithTaskError || err instanceof RetryWithTaskError || err instanceof CanceledWithTaskError || err instanceof YieldExecutionError || err instanceof AutoYieldExecutionError || err instanceof AutoYieldWithCompletedTaskExecutionError || err instanceof AutoYieldRateLimitError || err instanceof ResumeWithParallelTaskError;
338
345
  }
339
346
  __name(isTriggerError, "isTriggerError");
340
347
  var _ErrorWithTask = class _ErrorWithTask extends Error {
@@ -577,10 +584,12 @@ var _JSONOutputSerializer = class _JSONOutputSerializer {
577
584
  };
578
585
  __name(_JSONOutputSerializer, "JSONOutputSerializer");
579
586
  var JSONOutputSerializer = _JSONOutputSerializer;
580
- var _addToCachedTasks, addToCachedTasks_fn, _detectAutoYield, detectAutoYield_fn, _forceYield, forceYield_fn, _getTimeElapsed, getTimeElapsed_fn, _getRemainingTimeInMillis, getRemainingTimeInMillis_fn;
587
+ var _addToCachedTasks, addToCachedTasks_fn, _doRunTask, doRunTask_fn, _doCompleteTask, doCompleteTask_fn, _detectAutoYield, detectAutoYield_fn, _forceYield, forceYield_fn, _getTimeElapsed, getTimeElapsed_fn, _getRemainingTimeInMillis, getRemainingTimeInMillis_fn;
581
588
  var _IO = class _IO {
582
589
  constructor(options) {
583
590
  __privateAdd(this, _addToCachedTasks);
591
+ __privateAdd(this, _doRunTask);
592
+ __privateAdd(this, _doCompleteTask);
584
593
  __privateAdd(this, _detectAutoYield);
585
594
  __privateAdd(this, _forceYield);
586
595
  __privateAdd(this, _getTimeElapsed);
@@ -1440,15 +1449,17 @@ var _IO = class _IO {
1440
1449
  ...options ?? {},
1441
1450
  parseOutput: void 0
1442
1451
  };
1443
- const response = await this._apiClient.runTask(this._id, {
1452
+ const response = await __privateMethod(this, _doRunTask, doRunTask_fn).call(this, {
1444
1453
  idempotencyKey,
1445
1454
  displayKey: typeof cacheKey === "string" ? cacheKey : void 0,
1446
1455
  noop: false,
1447
1456
  ...runOptions ?? {},
1448
1457
  parentId
1449
- }, {
1450
- cachedTasksCursor: this._cachedTasksCursor
1451
1458
  });
1459
+ if (!response) {
1460
+ __privateMethod(this, _forceYield, forceYield_fn).call(this, "failed_task_run");
1461
+ throw new Error("Failed to run task");
1462
+ }
1452
1463
  const task = response.version === core.API_VERSIONS.LAZY_LOADED_CACHED_TASKS ? response.body.task : response.body;
1453
1464
  if (task.forceYield) {
1454
1465
  this._logger.debug("Forcing yield after run task", {
@@ -1514,10 +1525,14 @@ var _IO = class _IO {
1514
1525
  task
1515
1526
  });
1516
1527
  __privateMethod(this, _detectAutoYield, detectAutoYield_fn).call(this, "before_complete_task", 500, task, output);
1517
- const completedTask = await this._apiClient.completeTask(this._id, task.id, {
1528
+ const completedTask = await __privateMethod(this, _doCompleteTask, doCompleteTask_fn).call(this, task.id, {
1518
1529
  output,
1519
1530
  properties: task.outputProperties ?? void 0
1520
1531
  });
1532
+ if (!completedTask) {
1533
+ __privateMethod(this, _forceYield, forceYield_fn).call(this, "before_complete_task", task, output);
1534
+ throw new Error("Failed to complete task");
1535
+ }
1521
1536
  if (completedTask.forceYield) {
1522
1537
  this._logger.debug("Forcing yield after task completed", {
1523
1538
  idempotencyKey
@@ -1654,12 +1669,36 @@ _addToCachedTasks = new WeakSet();
1654
1669
  addToCachedTasks_fn = /* @__PURE__ */ __name(function(task) {
1655
1670
  this._cachedTasks.set(task.idempotencyKey, task);
1656
1671
  }, "#addToCachedTasks");
1672
+ _doRunTask = new WeakSet();
1673
+ doRunTask_fn = /* @__PURE__ */ __name(async function(task1) {
1674
+ try {
1675
+ return await this._apiClient.runTask(this._id, task1, {
1676
+ cachedTasksCursor: this._cachedTasksCursor
1677
+ });
1678
+ } catch (error) {
1679
+ if (error instanceof AutoYieldRateLimitError) {
1680
+ this._logger.debug("AutoYieldRateLimitError", {
1681
+ error
1682
+ });
1683
+ throw error;
1684
+ }
1685
+ return;
1686
+ }
1687
+ }, "#doRunTask");
1688
+ _doCompleteTask = new WeakSet();
1689
+ doCompleteTask_fn = /* @__PURE__ */ __name(async function(id, task2) {
1690
+ try {
1691
+ return await this._apiClient.completeTask(this._id, id, task2);
1692
+ } catch (error) {
1693
+ return;
1694
+ }
1695
+ }, "#doCompleteTask");
1657
1696
  _detectAutoYield = new WeakSet();
1658
- detectAutoYield_fn = /* @__PURE__ */ __name(function(location, threshold = 1500, task1, output) {
1697
+ detectAutoYield_fn = /* @__PURE__ */ __name(function(location, threshold = 1500, task3, output) {
1659
1698
  const timeRemaining = __privateMethod(this, _getRemainingTimeInMillis, getRemainingTimeInMillis_fn).call(this);
1660
1699
  if (timeRemaining && timeRemaining < threshold) {
1661
- if (task1) {
1662
- throw new AutoYieldWithCompletedTaskExecutionError(task1.id, task1.outputProperties ?? [], {
1700
+ if (task3) {
1701
+ throw new AutoYieldWithCompletedTaskExecutionError(task3.id, task3.outputProperties ?? [], {
1663
1702
  location,
1664
1703
  timeRemaining,
1665
1704
  timeElapsed: __privateMethod(this, _getTimeElapsed, getTimeElapsed_fn).call(this)
@@ -1670,10 +1709,18 @@ detectAutoYield_fn = /* @__PURE__ */ __name(function(location, threshold = 1500,
1670
1709
  }
1671
1710
  }, "#detectAutoYield");
1672
1711
  _forceYield = new WeakSet();
1673
- forceYield_fn = /* @__PURE__ */ __name(function(location1) {
1712
+ forceYield_fn = /* @__PURE__ */ __name(function(location1, task4, output1) {
1674
1713
  const timeRemaining = __privateMethod(this, _getRemainingTimeInMillis, getRemainingTimeInMillis_fn).call(this);
1675
1714
  if (timeRemaining) {
1676
- throw new AutoYieldExecutionError(location1, timeRemaining, __privateMethod(this, _getTimeElapsed, getTimeElapsed_fn).call(this));
1715
+ if (task4) {
1716
+ throw new AutoYieldWithCompletedTaskExecutionError(task4.id, task4.outputProperties ?? [], {
1717
+ location: location1,
1718
+ timeRemaining,
1719
+ timeElapsed: __privateMethod(this, _getTimeElapsed, getTimeElapsed_fn).call(this)
1720
+ }, output1);
1721
+ } else {
1722
+ throw new AutoYieldExecutionError(location1, timeRemaining, __privateMethod(this, _getTimeElapsed, getTimeElapsed_fn).call(this));
1723
+ }
1677
1724
  }
1678
1725
  }, "#forceYield");
1679
1726
  _getTimeElapsed = new WeakSet();
@@ -1843,6 +1890,18 @@ __name(_KeyValueStoreClient, "KeyValueStoreClient");
1843
1890
  var KeyValueStoreClient = _KeyValueStoreClient;
1844
1891
 
1845
1892
  // src/apiClient.ts
1893
+ var _UnknownVersionError = class _UnknownVersionError extends Error {
1894
+ constructor(version2) {
1895
+ super(`Unknown version ${version2}`);
1896
+ }
1897
+ };
1898
+ __name(_UnknownVersionError, "UnknownVersionError");
1899
+ var UnknownVersionError = _UnknownVersionError;
1900
+ var MAX_RETRIES = 8;
1901
+ var EXPONENT_FACTOR = 2;
1902
+ var MIN_DELAY_IN_MS = 80;
1903
+ var MAX_DELAY_IN_MS = 2e3;
1904
+ var JITTER_IN_MS = 50;
1846
1905
  var _apiUrl, _options, _logger, _storeClient, _queryKeyValueStore, queryKeyValueStore_fn, _apiKey, apiKey_fn;
1847
1906
  var _ApiClient = class _ApiClient {
1848
1907
  constructor(options) {
@@ -1885,10 +1944,8 @@ var _ApiClient = class _ApiClient {
1885
1944
  }
1886
1945
  async runTask(runId, task, options = {}) {
1887
1946
  const apiKey = await __privateMethod(this, _apiKey, apiKey_fn).call(this);
1888
- __privateGet(this, _logger).debug("Running Task", {
1889
- task
1890
- });
1891
- return await zodfetchWithVersions({
1947
+ __privateGet(this, _logger).debug(`[ApiClient] runTask ${task.displayKey}`);
1948
+ return await zodfetchWithVersions(__privateGet(this, _logger), {
1892
1949
  [core.API_VERSIONS.LAZY_LOADED_CACHED_TASKS]: core.RunTaskResponseWithCachedTasksBodySchema
1893
1950
  }, core.ServerTaskSchema, `${__privateGet(this, _apiUrl)}/api/v1/runs/${runId}/tasks`, {
1894
1951
  method: "POST",
@@ -2323,39 +2380,91 @@ function getApiKey(key) {
2323
2380
  };
2324
2381
  }
2325
2382
  __name(getApiKey, "getApiKey");
2326
- async function zodfetchWithVersions(versionedSchemaMap, unversionedSchema, url, requestInit, options, retryCount = 0) {
2327
- const response = await fetch(url, requestInitWithCache(requestInit));
2328
- if ((!requestInit || requestInit.method === "GET") && response.status === 404 && options?.optional) {
2329
- return;
2330
- }
2331
- if (response.status >= 400 && response.status < 500) {
2332
- const body = await response.json();
2333
- throw new Error(body.error);
2334
- }
2335
- if (response.status >= 500 && retryCount < 6) {
2336
- const delay = exponentialBackoff(retryCount + 1, 2, 50, 1150, 50);
2337
- await new Promise((resolve) => setTimeout(resolve, delay));
2338
- return zodfetchWithVersions(versionedSchemaMap, unversionedSchema, url, requestInit, options, retryCount + 1);
2339
- }
2340
- if (response.status !== 200) {
2341
- throw new Error(options?.errorMessage ?? `Failed to fetch ${url}, got status code ${response.status}`);
2342
- }
2343
- const jsonBody = await response.json();
2344
- const version2 = response.headers.get("trigger-version");
2345
- if (!version2) {
2383
+ async function zodfetchWithVersions(logger, versionedSchemaMap, unversionedSchema, url, requestInit, options, retryCount = 0) {
2384
+ try {
2385
+ const fullRequestInit = requestInitWithCache(requestInit);
2386
+ const response = await fetch(url, fullRequestInit);
2387
+ logger.debug(`[ApiClient] zodfetchWithVersions ${url} (attempt ${retryCount + 1})`, {
2388
+ url,
2389
+ retryCount,
2390
+ requestHeaders: fullRequestInit?.headers,
2391
+ responseHeaders: Object.fromEntries(response.headers.entries())
2392
+ });
2393
+ if ((!requestInit || requestInit.method === "GET") && response.status === 404 && options?.optional) {
2394
+ return;
2395
+ }
2396
+ if (response.status === 429) {
2397
+ const retryAfter = response.headers.get("x-ratelimit-reset");
2398
+ if (retryAfter) {
2399
+ throw new AutoYieldRateLimitError(parseInt(retryAfter));
2400
+ }
2401
+ }
2402
+ if (response.status >= 400 && response.status < 500) {
2403
+ const rawBody = await safeResponseText(response);
2404
+ const body = safeJsonParse(rawBody);
2405
+ logger.error(`[ApiClient] zodfetchWithVersions failed with ${response.status}`, {
2406
+ url,
2407
+ retryCount,
2408
+ requestHeaders: fullRequestInit?.headers,
2409
+ responseHeaders: Object.fromEntries(response.headers.entries()),
2410
+ status: response.status,
2411
+ rawBody
2412
+ });
2413
+ if (body && body.error) {
2414
+ throw new Error(body.error);
2415
+ } else {
2416
+ throw new Error(rawBody);
2417
+ }
2418
+ }
2419
+ if (response.status >= 500 && retryCount < MAX_RETRIES) {
2420
+ const delay = exponentialBackoff(retryCount + 1);
2421
+ await new Promise((resolve) => setTimeout(resolve, delay));
2422
+ return zodfetchWithVersions(logger, versionedSchemaMap, unversionedSchema, url, requestInit, options, retryCount + 1);
2423
+ }
2424
+ if (response.status !== 200) {
2425
+ const rawBody = await safeResponseText(response);
2426
+ logger.error(`[ApiClient] zodfetchWithVersions failed with ${response.status}`, {
2427
+ url,
2428
+ retryCount,
2429
+ requestHeaders: fullRequestInit?.headers,
2430
+ responseHeaders: Object.fromEntries(response.headers.entries()),
2431
+ status: response.status,
2432
+ rawBody
2433
+ });
2434
+ throw new Error(options?.errorMessage ?? `Failed to fetch ${url}, got status code ${response.status}`);
2435
+ }
2436
+ const jsonBody = await response.json();
2437
+ const version2 = response.headers.get("trigger-version");
2438
+ if (!version2) {
2439
+ return {
2440
+ version: "unversioned",
2441
+ body: unversionedSchema.parse(jsonBody)
2442
+ };
2443
+ }
2444
+ const versionedSchema = versionedSchemaMap[version2];
2445
+ if (!versionedSchema) {
2446
+ throw new UnknownVersionError(version2);
2447
+ }
2346
2448
  return {
2347
- version: "unversioned",
2348
- body: unversionedSchema.parse(jsonBody)
2449
+ version: version2,
2450
+ body: versionedSchema.parse(jsonBody)
2349
2451
  };
2452
+ } catch (error) {
2453
+ if (error instanceof UnknownVersionError || error instanceof AutoYieldRateLimitError) {
2454
+ throw error;
2455
+ }
2456
+ logger.error(`[ApiClient] zodfetchWithVersions failed with a connection error`, {
2457
+ url,
2458
+ retryCount,
2459
+ error
2460
+ });
2461
+ if (retryCount < MAX_RETRIES) {
2462
+ const delay = exponentialBackoff(retryCount + 1);
2463
+ await new Promise((resolve) => setTimeout(resolve, delay));
2464
+ return zodfetchWithVersions(logger, versionedSchemaMap, unversionedSchema, url, requestInit, options, retryCount + 1);
2465
+ }
2466
+ throw error;
2350
2467
  }
2351
- const versionedSchema = versionedSchemaMap[version2];
2352
- if (!versionedSchema) {
2353
- throw new Error(`Unknown version ${version2}`);
2354
- }
2355
- return {
2356
- version: version2,
2357
- body: versionedSchema.parse(jsonBody)
2358
- };
2359
2468
  }
2360
2469
  __name(zodfetchWithVersions, "zodfetchWithVersions");
2361
2470
  function requestInitWithCache(requestInit) {
@@ -2377,8 +2486,8 @@ async function fetchHead(url, requestInitWithoutMethod, retryCount = 0) {
2377
2486
  method: "HEAD"
2378
2487
  };
2379
2488
  const response = await fetch(url, requestInitWithCache(requestInit));
2380
- if (response.status >= 500 && retryCount < 6) {
2381
- const delay = exponentialBackoff(retryCount + 1, 2, 50, 1150, 50);
2489
+ if (response.status >= 500 && retryCount < MAX_RETRIES) {
2490
+ const delay = exponentialBackoff(retryCount + 1);
2382
2491
  await new Promise((resolve) => setTimeout(resolve, delay));
2383
2492
  return fetchHead(url, requestInitWithoutMethod, retryCount + 1);
2384
2493
  }
@@ -2386,32 +2495,66 @@ async function fetchHead(url, requestInitWithoutMethod, retryCount = 0) {
2386
2495
  }
2387
2496
  __name(fetchHead, "fetchHead");
2388
2497
  async function zodfetch(schema, url, requestInit, options, retryCount = 0) {
2389
- const response = await fetch(url, requestInitWithCache(requestInit));
2390
- if ((!requestInit || requestInit.method === "GET") && response.status === 404 && options?.optional) {
2391
- return;
2392
- }
2393
- if (response.status >= 400 && response.status < 500) {
2394
- const body = await response.json();
2395
- throw new Error(body.error);
2396
- }
2397
- if (response.status >= 500 && retryCount < 6) {
2398
- const delay = exponentialBackoff(retryCount + 1, 2, 50, 1150, 50);
2399
- await new Promise((resolve) => setTimeout(resolve, delay));
2400
- return zodfetch(schema, url, requestInit, options, retryCount + 1);
2401
- }
2402
- if (response.status !== 200) {
2403
- throw new Error(options?.errorMessage ?? `Failed to fetch ${url}, got status code ${response.status}`);
2498
+ try {
2499
+ const response = await fetch(url, requestInitWithCache(requestInit));
2500
+ if ((!requestInit || requestInit.method === "GET") && response.status === 404 && options?.optional) {
2501
+ return;
2502
+ }
2503
+ if (response.status === 429) {
2504
+ const retryAfter = response.headers.get("x-ratelimit-reset");
2505
+ if (retryAfter) {
2506
+ throw new AutoYieldRateLimitError(parseInt(retryAfter));
2507
+ }
2508
+ }
2509
+ if (response.status >= 400 && response.status < 500) {
2510
+ const body = await response.json();
2511
+ throw new Error(body.error);
2512
+ }
2513
+ if (response.status >= 500 && retryCount < MAX_RETRIES) {
2514
+ const delay = exponentialBackoff(retryCount + 1);
2515
+ await new Promise((resolve) => setTimeout(resolve, delay));
2516
+ return zodfetch(schema, url, requestInit, options, retryCount + 1);
2517
+ }
2518
+ if (response.status !== 200) {
2519
+ throw new Error(options?.errorMessage ?? `Failed to fetch ${url}, got status code ${response.status}`);
2520
+ }
2521
+ const jsonBody = await response.json();
2522
+ return schema.parse(jsonBody);
2523
+ } catch (error) {
2524
+ if (error instanceof AutoYieldRateLimitError) {
2525
+ throw error;
2526
+ }
2527
+ if (retryCount < MAX_RETRIES) {
2528
+ const delay = exponentialBackoff(retryCount + 1);
2529
+ await new Promise((resolve) => setTimeout(resolve, delay));
2530
+ return zodfetch(schema, url, requestInit, options, retryCount + 1);
2531
+ }
2532
+ throw error;
2404
2533
  }
2405
- const jsonBody = await response.json();
2406
- return schema.parse(jsonBody);
2407
2534
  }
2408
2535
  __name(zodfetch, "zodfetch");
2409
- function exponentialBackoff(retryCount, exponential, minDelay, maxDelay, jitter) {
2410
- const delay = Math.min(Math.pow(exponential, retryCount) * minDelay, maxDelay);
2411
- const jitterValue = Math.random() * jitter;
2536
+ function exponentialBackoff(retryCount) {
2537
+ const delay = Math.min(Math.pow(EXPONENT_FACTOR, retryCount) * MIN_DELAY_IN_MS, MAX_DELAY_IN_MS);
2538
+ const jitterValue = Math.random() * JITTER_IN_MS;
2412
2539
  return delay + jitterValue;
2413
2540
  }
2414
2541
  __name(exponentialBackoff, "exponentialBackoff");
2542
+ function safeJsonParse(rawBody) {
2543
+ try {
2544
+ return JSON.parse(rawBody);
2545
+ } catch (error) {
2546
+ return;
2547
+ }
2548
+ }
2549
+ __name(safeJsonParse, "safeJsonParse");
2550
+ async function safeResponseText(response) {
2551
+ try {
2552
+ return await response.text();
2553
+ } catch (error) {
2554
+ return "";
2555
+ }
2556
+ }
2557
+ __name(safeResponseText, "safeResponseText");
2415
2558
 
2416
2559
  // src/concurrencyLimit.ts
2417
2560
  var _ConcurrencyLimit = class _ConcurrencyLimit {
@@ -3027,11 +3170,14 @@ var _TriggerClient = class _TriggerClient {
3027
3170
  __publicField(this, "on", __privateGet(this, _eventEmitter).on.bind(__privateGet(this, _eventEmitter)));
3028
3171
  this.id = options.id;
3029
3172
  __privateSet(this, _options4, options);
3030
- __privateSet(this, _client2, new ApiClient(__privateGet(this, _options4)));
3031
3173
  __privateSet(this, _internalLogger, new coreBackend.Logger("trigger.dev", __privateGet(this, _options4).verbose ? "debug" : "log", [
3032
3174
  "output",
3033
3175
  "noopTasksSet"
3034
3176
  ]));
3177
+ __privateSet(this, _client2, new ApiClient({
3178
+ logLevel: __privateGet(this, _options4).verbose ? "debug" : "log",
3179
+ ...__privateGet(this, _options4)
3180
+ }));
3035
3181
  __privateSet(this, _envStore, new KeyValueStore(__privateGet(this, _client2)));
3036
3182
  }
3037
3183
  async handleRequest(request, timeOrigin = performance.now()) {
@@ -3858,6 +4004,12 @@ convertErrorToExecutionResponse_fn = /* @__PURE__ */ __name(function(error, body
3858
4004
  }
3859
4005
  };
3860
4006
  }
4007
+ if (error instanceof AutoYieldRateLimitError) {
4008
+ return {
4009
+ status: "AUTO_YIELD_RATE_LIMIT",
4010
+ reset: error.resetAtTimestamp
4011
+ };
4012
+ }
3861
4013
  if (error instanceof YieldExecutionError) {
3862
4014
  return {
3863
4015
  status: "YIELD_EXECUTION",