@rivetkit/supabase 2.3.12-rc.1 → 2.3.12-rc.3

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.
Files changed (3) hide show
  1. package/dist/mod.js +135 -70
  2. package/dist/mod.mjs +135 -70
  3. package/package.json +3 -3
package/dist/mod.js CHANGED
@@ -335,13 +335,13 @@ __export(mod_exports, {
335
335
  module.exports = __toCommonJS(mod_exports);
336
336
  var wasmBindings = __toESM(require("@rivetkit/rivetkit-wasm"));
337
337
 
338
- // ../rivetkit/dist/tsup/chunk-ZZ3WBRPD.js
338
+ // ../rivetkit/dist/tsup/chunk-IXBD7BXC.js
339
339
  var INTERNAL_ERROR_CODE = "internal_error";
340
340
  var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
341
341
  var USER_ERROR_CODE = "user_error";
342
342
  var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
343
343
  function looksLikeRivetErrorOptions(value) {
344
- return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "statusCode" in value || "actor" in value || "cause" in value);
344
+ return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
345
345
  }
346
346
  function isTypedErrorTag(value) {
347
347
  return value === "ActorError" || value === "RivetError";
@@ -353,7 +353,7 @@ function errorMessage(error46, fallback = String(error46)) {
353
353
  return fallback;
354
354
  }
355
355
  function isRivetErrorLike(error46) {
356
- return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("__type" in error46) || isTypedErrorTag(error46.__type));
356
+ return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("rayId" in error46) || error46.rayId === void 0 || typeof error46.rayId === "string") && (!("__type" in error46) || isTypedErrorTag(error46.__type));
357
357
  }
358
358
  function isActorAbortedError(error46) {
359
359
  return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
@@ -365,6 +365,7 @@ var RivetError = class extends Error {
365
365
  __type = "RivetError";
366
366
  public;
367
367
  metadata;
368
+ rayId;
368
369
  statusCode;
369
370
  actor;
370
371
  group;
@@ -383,6 +384,7 @@ var RivetError = class extends Error {
383
384
  this.code = code;
384
385
  this.public = normalized.public ?? false;
385
386
  this.metadata = normalized.metadata;
387
+ this.rayId = normalized.rayId ?? void 0;
386
388
  this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
387
389
  this.actor = normalized.actor;
388
390
  }
@@ -417,6 +419,7 @@ function toRivetError(error46, fallback) {
417
419
  public: error46.public,
418
420
  statusCode: error46.statusCode,
419
421
  metadata: error46.metadata,
422
+ rayId: error46.rayId,
420
423
  actor: error46.actor,
421
424
  cause: error46 instanceof Error ? error46.cause : void 0
422
425
  });
@@ -429,6 +432,7 @@ function toRivetError(error46, fallback) {
429
432
  public: fallback == null ? void 0 : fallback.public,
430
433
  statusCode: fallback == null ? void 0 : fallback.statusCode,
431
434
  metadata: fallback == null ? void 0 : fallback.metadata,
435
+ rayId: fallback == null ? void 0 : fallback.rayId,
432
436
  actor: fallback == null ? void 0 : fallback.actor,
433
437
  cause: error46 instanceof Error ? error46 : void 0
434
438
  }
@@ -440,6 +444,7 @@ function encodeBridgeRivetError(error46) {
440
444
  code: error46.code,
441
445
  message: error46.message,
442
446
  metadata: error46.metadata,
447
+ rayId: error46.rayId,
443
448
  public: error46.public,
444
449
  statusCode: error46.statusCode,
445
450
  actor: error46.actor
@@ -450,9 +455,13 @@ function decodeBridgeRivetErrorPayload(value) {
450
455
  return void 0;
451
456
  }
452
457
  try {
453
- const payload = JSON.parse(
458
+ const raw = JSON.parse(
454
459
  value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
455
460
  );
461
+ const payload = {
462
+ ...raw,
463
+ rayId: raw.rayId ?? void 0
464
+ };
456
465
  if (!isRivetErrorLike(payload)) {
457
466
  return void 0;
458
467
  }
@@ -471,6 +480,7 @@ function decodeBridgeRivetError(value) {
471
480
  }
472
481
  return new RivetError(payload.group, payload.code, payload.message, {
473
482
  metadata: payload.metadata,
483
+ rayId: payload.rayId,
474
484
  public: payload.public,
475
485
  statusCode: payload.statusCode,
476
486
  actor: payload.actor ?? void 0
@@ -509,7 +519,7 @@ function unsupportedFeature(feature) {
509
519
  );
510
520
  }
511
521
 
512
- // ../rivetkit/dist/tsup/chunk-HVHDZDM2.js
522
+ // ../rivetkit/dist/tsup/chunk-OLGQYFUW.js
513
523
  var import_pino = require("pino");
514
524
 
515
525
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
@@ -13182,7 +13192,7 @@ var classic_default = external_exports;
13182
13192
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
13183
13193
  var v4_default = classic_default;
13184
13194
 
13185
- // ../rivetkit/dist/tsup/chunk-HVHDZDM2.js
13195
+ // ../rivetkit/dist/tsup/chunk-OLGQYFUW.js
13186
13196
  var cbor = __toESM(require("cbor-x"), 1);
13187
13197
  var import_invariant = __toESM(require_invariant(), 1);
13188
13198
  var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
@@ -13251,6 +13261,7 @@ function deconstructError(error46, exposeInternalError = false) {
13251
13261
  let code;
13252
13262
  let message;
13253
13263
  let metadata;
13264
+ let rayId;
13254
13265
  let actor2;
13255
13266
  if (isCanonicalStructuredRivetError(error46)) {
13256
13267
  statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
@@ -13259,6 +13270,7 @@ function deconstructError(error46, exposeInternalError = false) {
13259
13270
  code = error46.code;
13260
13271
  message = error46.message;
13261
13272
  metadata = error46.metadata;
13273
+ rayId = error46.rayId;
13262
13274
  actor2 = error46.actor;
13263
13275
  } else if (RivetError.isActorError(error46) && error46.public) {
13264
13276
  statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
@@ -13267,6 +13279,7 @@ function deconstructError(error46, exposeInternalError = false) {
13267
13279
  code = error46.code;
13268
13280
  message = getErrorMessage(error46);
13269
13281
  metadata = error46.metadata;
13282
+ rayId = error46.rayId;
13270
13283
  actor2 = error46.actor;
13271
13284
  } else if (exposeInternalError) {
13272
13285
  if (RivetError.isActorError(error46)) {
@@ -13276,6 +13289,7 @@ function deconstructError(error46, exposeInternalError = false) {
13276
13289
  code = error46.code;
13277
13290
  message = getErrorMessage(error46);
13278
13291
  metadata = error46.metadata;
13292
+ rayId = error46.rayId;
13279
13293
  actor2 = error46.actor;
13280
13294
  } else {
13281
13295
  statusCode = 500;
@@ -13305,6 +13319,7 @@ function deconstructError(error46, exposeInternalError = false) {
13305
13319
  code,
13306
13320
  message,
13307
13321
  metadata,
13322
+ rayId,
13308
13323
  actor: actor2
13309
13324
  };
13310
13325
  }
@@ -13347,7 +13362,7 @@ function noopNext() {
13347
13362
  }
13348
13363
  var package_default = {
13349
13364
  name: "rivetkit",
13350
- version: "2.3.12-rc.1",
13365
+ version: "2.3.12-rc.3",
13351
13366
  description: "Lightweight libraries for building stateful actors on edge platforms",
13352
13367
  license: "Apache-2.0",
13353
13368
  keywords: [
@@ -14650,7 +14665,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
14650
14665
  };
14651
14666
  }
14652
14667
 
14653
- // ../rivetkit/dist/tsup/chunk-5UYNV4W6.js
14668
+ // ../rivetkit/dist/tsup/chunk-WVFTFWJL.js
14654
14669
  var config2 = /* @__PURE__ */ Config({});
14655
14670
  function readWorkflowCbor(bc) {
14656
14671
  return readData(bc);
@@ -15612,7 +15627,7 @@ var AsyncMutex = class {
15612
15627
  }
15613
15628
  };
15614
15629
 
15615
- // ../rivetkit/dist/tsup/chunk-JHHAMABO.js
15630
+ // ../rivetkit/dist/tsup/chunk-XI4MEUUI.js
15616
15631
  function logger() {
15617
15632
  return getLogger("actor-client");
15618
15633
  }
@@ -15650,7 +15665,7 @@ async function importWebSocket() {
15650
15665
  return webSocketPromise;
15651
15666
  }
15652
15667
 
15653
- // ../rivetkit/dist/tsup/chunk-A5BZEQOG.js
15668
+ // ../rivetkit/dist/tsup/chunk-YYIDQBBM.js
15654
15669
  var import_invariant2 = __toESM(require_invariant(), 1);
15655
15670
 
15656
15671
  // ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
@@ -15828,7 +15843,7 @@ function createVersionedDataHandler(config3) {
15828
15843
  return new VersionedDataHandler(config3);
15829
15844
  }
15830
15845
 
15831
- // ../rivetkit/dist/tsup/chunk-A5BZEQOG.js
15846
+ // ../rivetkit/dist/tsup/chunk-YYIDQBBM.js
15832
15847
  var import_invariant3 = __toESM(require_invariant(), 1);
15833
15848
  var import_invariant4 = __toESM(require_invariant(), 1);
15834
15849
  var PATH_CONNECT = "/connect";
@@ -15883,12 +15898,12 @@ var ActorConnDisposed = class extends ActorClientError {
15883
15898
  function isSchedulingError(group, code) {
15884
15899
  return group === "guard" && (code === "actor_ready_timeout" || code === "actor_runner_failed");
15885
15900
  }
15886
- function actorSchedulingError(group, code, actorId, details) {
15901
+ function actorSchedulingError(group, code, actorId, details, rayId) {
15887
15902
  return new RivetError(
15888
15903
  group,
15889
15904
  code,
15890
15905
  `Actor failed to start (${actorId}): ${JSON.stringify(details)}`,
15891
- { metadata: { actorId, details } }
15906
+ { metadata: { actorId, details }, rayId }
15892
15907
  );
15893
15908
  }
15894
15909
  function internalClientError(message, opts) {
@@ -17868,7 +17883,7 @@ function getGatewayTarget(state) {
17868
17883
  function isStaleResolvedActorError(group, code) {
17869
17884
  return group === "actor" && (code === "not_found" || code === "starting" || code === "stopping" || code === "not_configured" || code === "dropped_reply" || code.startsWith("destroyed_"));
17870
17885
  }
17871
- async function checkForSchedulingError(group, code, actorId, query, driver) {
17886
+ async function checkForSchedulingError(group, code, actorId, query, driver, rayId) {
17872
17887
  const name = getActorNameFromQuery(query);
17873
17888
  try {
17874
17889
  const actor2 = await driver.getForId({ name, actorId });
@@ -17878,7 +17893,13 @@ async function checkForSchedulingError(group, code, actorId, query, driver) {
17878
17893
  actorId,
17879
17894
  error: actor2.error
17880
17895
  });
17881
- return actorSchedulingError(group, code, actorId, actor2.error);
17896
+ return actorSchedulingError(
17897
+ group,
17898
+ code,
17899
+ actorId,
17900
+ actor2.error,
17901
+ rayId
17902
+ );
17882
17903
  }
17883
17904
  } catch (err) {
17884
17905
  logger().warn({
@@ -18195,6 +18216,7 @@ async function sendHttpRequest(opts) {
18195
18216
  code: responseData.code,
18196
18217
  message: responseData.message,
18197
18218
  metadata: responseData.metadata,
18219
+ rayId,
18198
18220
  actorId: (_a2 = responseData.actor) == null ? void 0 : _a2.actorId,
18199
18221
  generation: (_b = responseData.actor) == null ? void 0 : _b.generation,
18200
18222
  actorKey: (_c = responseData.actor) == null ? void 0 : _c.key
@@ -18205,6 +18227,7 @@ async function sendHttpRequest(opts) {
18205
18227
  responseData.message,
18206
18228
  {
18207
18229
  metadata: responseData.metadata,
18230
+ rayId: rayId ?? void 0,
18208
18231
  actor: responseData.actor
18209
18232
  }
18210
18233
  );
@@ -18384,11 +18407,8 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}) {
18384
18407
  });
18385
18408
  return driver.sendRequest(target, proxyRequest, options);
18386
18409
  } catch (err) {
18387
- const { group, code, message, metadata, actor: actor2 } = deconstructError(
18388
- err,
18389
- true
18390
- );
18391
- throw new RivetError(group, code, message, { metadata, actor: actor2 });
18410
+ const { group, code, message, metadata, rayId, actor: actor2 } = deconstructError(err, true);
18411
+ throw new RivetError(group, code, message, { metadata, rayId, actor: actor2 });
18392
18412
  }
18393
18413
  }
18394
18414
  async function rawWebSocket(driver, target, params, path2, _protocols, options = {}) {
@@ -18503,7 +18523,7 @@ var ActorHandleRaw = class {
18503
18523
  async #sendQueueMessage(name, body, options) {
18504
18524
  return await this.#queueSendMutex.run(async () => {
18505
18525
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
18506
- let useQueryTarget = false;
18526
+ let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
18507
18527
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
18508
18528
  let actorId;
18509
18529
  try {
@@ -18527,7 +18547,7 @@ var ActorHandleRaw = class {
18527
18547
  }
18528
18548
  }).send(name, body, options);
18529
18549
  } catch (err) {
18530
- const { group, code, message, metadata, actor: actor2 } = deconstructError(err, true);
18550
+ const { group, code, message, metadata, rayId, actor: actor2 } = deconstructError(err, true);
18531
18551
  if (this.#shouldRetryQueueDispatchOverload(
18532
18552
  group,
18533
18553
  code,
@@ -18543,7 +18563,8 @@ var ActorHandleRaw = class {
18543
18563
  code,
18544
18564
  actorId,
18545
18565
  attempt,
18546
- maxAttempts
18566
+ maxAttempts,
18567
+ rayId
18547
18568
  )) {
18548
18569
  useQueryTarget = true;
18549
18570
  await this.#waitForRetryWindow();
@@ -18565,14 +18586,16 @@ var ActorHandleRaw = class {
18565
18586
  code
18566
18587
  );
18567
18588
  if (invalidated && attempt < maxAttempts - 1) {
18568
- useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18569
- if (useQueryTarget) {
18589
+ const waitForReady = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18590
+ useQueryTarget = useQueryTarget || waitForReady;
18591
+ if (waitForReady) {
18570
18592
  await this.#waitForRetryWindow();
18571
18593
  }
18572
18594
  continue;
18573
18595
  }
18574
18596
  throw new RivetError(group, code, message, {
18575
18597
  metadata,
18598
+ rayId,
18576
18599
  actor: actor2
18577
18600
  });
18578
18601
  }
@@ -18601,7 +18624,7 @@ var ActorHandleRaw = class {
18601
18624
  }
18602
18625
  async #sendActionNow(opts) {
18603
18626
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
18604
- let useQueryTarget = false;
18627
+ let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
18605
18628
  const gatewayOptions = resolveActorGatewayOptions(
18606
18629
  this.#gatewayOptions,
18607
18630
  opts
@@ -18666,13 +18689,14 @@ var ActorHandleRaw = class {
18666
18689
  }
18667
18690
  return output;
18668
18691
  } catch (err) {
18669
- const { group, code, message, metadata, actor: actor2 } = deconstructError(err, true);
18692
+ const { group, code, message, metadata, rayId, actor: actor2 } = deconstructError(err, true);
18670
18693
  if (await this.#shouldRetrySchedulingError(
18671
18694
  group,
18672
18695
  code,
18673
18696
  actorId,
18674
18697
  attempt,
18675
- maxAttempts
18698
+ maxAttempts,
18699
+ rayId
18676
18700
  )) {
18677
18701
  useQueryTarget = true;
18678
18702
  await this.#waitForRetryWindow();
@@ -18694,7 +18718,7 @@ var ActorHandleRaw = class {
18694
18718
  "actor",
18695
18719
  "not_found",
18696
18720
  "The actor does not exist or was destroyed.",
18697
- { metadata, actor: actor2 }
18721
+ { metadata, rayId, actor: actor2 }
18698
18722
  );
18699
18723
  }
18700
18724
  const invalidated = this.#invalidateResolvedActorId(
@@ -18710,7 +18734,11 @@ var ActorHandleRaw = class {
18710
18734
  }
18711
18735
  continue;
18712
18736
  }
18713
- throw new RivetError(group, code, message, { metadata, actor: actor2 });
18737
+ throw new RivetError(group, code, message, {
18738
+ metadata,
18739
+ rayId,
18740
+ actor: actor2
18741
+ });
18714
18742
  }
18715
18743
  }
18716
18744
  throw new Error("unreachable action retry state");
@@ -18752,7 +18780,7 @@ var ActorHandleRaw = class {
18752
18780
  this.#resolvedActorId = void 0;
18753
18781
  this.#resolvingActorId = void 0;
18754
18782
  }
18755
- async #shouldRetrySchedulingError(group, code, actorId, attempt, maxAttempts) {
18783
+ async #shouldRetrySchedulingError(group, code, actorId, attempt, maxAttempts, rayId) {
18756
18784
  if (!isDynamicActorQuery(this.#actorResolutionState) || !isSchedulingError(group, code) || attempt >= maxAttempts - 1) {
18757
18785
  return false;
18758
18786
  }
@@ -18762,7 +18790,8 @@ var ActorHandleRaw = class {
18762
18790
  code,
18763
18791
  actorId,
18764
18792
  this.#actorResolutionState,
18765
- this.#driver
18793
+ this.#driver,
18794
+ rayId
18766
18795
  );
18767
18796
  if (schedulingError) {
18768
18797
  throw schedulingError;
@@ -18844,7 +18873,7 @@ var ActorHandleRaw = class {
18844
18873
  }
18845
18874
  async #fetchWithResolvedActor(input, init) {
18846
18875
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
18847
- let useQueryTarget = false;
18876
+ let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
18848
18877
  const { skipReadyWait, ...requestInit } = init ?? {};
18849
18878
  const gatewayOptions = resolveActorGatewayOptions(
18850
18879
  this.#gatewayOptions,
@@ -18883,13 +18912,14 @@ var ActorHandleRaw = class {
18883
18912
  }
18884
18913
  return response;
18885
18914
  } catch (err) {
18886
- const { group, code, message, metadata, actor: actor2 } = deconstructError(err, true);
18915
+ const { group, code, message, metadata, rayId, actor: actor2 } = deconstructError(err, true);
18887
18916
  if (await this.#shouldRetrySchedulingError(
18888
18917
  group,
18889
18918
  code,
18890
18919
  actorId,
18891
18920
  attempt,
18892
- maxAttempts
18921
+ maxAttempts,
18922
+ rayId
18893
18923
  )) {
18894
18924
  useQueryTarget = true;
18895
18925
  await this.#waitForRetryWindow();
@@ -18911,13 +18941,18 @@ var ActorHandleRaw = class {
18911
18941
  code
18912
18942
  );
18913
18943
  if (invalidated && attempt < maxAttempts - 1) {
18914
- useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18915
- if (useQueryTarget) {
18944
+ const waitForReady = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18945
+ useQueryTarget = useQueryTarget || waitForReady;
18946
+ if (waitForReady) {
18916
18947
  await this.#waitForRetryWindow();
18917
18948
  }
18918
18949
  continue;
18919
18950
  }
18920
- throw new RivetError(group, code, message, { metadata, actor: actor2 });
18951
+ throw new RivetError(group, code, message, {
18952
+ metadata,
18953
+ rayId,
18954
+ actor: actor2
18955
+ });
18921
18956
  }
18922
18957
  }
18923
18958
  throw new Error("unreachable fetch retry state");
@@ -18930,13 +18965,14 @@ var ActorHandleRaw = class {
18930
18965
  if (!error46) {
18931
18966
  return null;
18932
18967
  }
18933
- const { group, code } = error46;
18968
+ const { group, code, rayId } = error46;
18934
18969
  if (await this.#shouldRetrySchedulingError(
18935
18970
  group,
18936
18971
  code,
18937
18972
  actorId,
18938
18973
  attempt,
18939
- maxAttempts
18974
+ maxAttempts,
18975
+ rayId
18940
18976
  )) {
18941
18977
  return {
18942
18978
  useQueryTarget: true,
@@ -18957,10 +18993,10 @@ var ActorHandleRaw = class {
18957
18993
  }
18958
18994
  const invalidated = this.#invalidateResolvedActorId(group, code);
18959
18995
  if (invalidated && attempt < maxAttempts - 1) {
18960
- const useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18996
+ const waitForReady = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18961
18997
  return {
18962
- useQueryTarget,
18963
- waitForRetryWindow: useQueryTarget
18998
+ useQueryTarget: true,
18999
+ waitForRetryWindow: waitForReady
18964
19000
  };
18965
19001
  }
18966
19002
  return null;
@@ -18972,7 +19008,7 @@ var ActorHandleRaw = class {
18972
19008
  const contentType = response.headers.get("content-type");
18973
19009
  const encoding = (contentType == null ? void 0 : contentType.includes("application/json")) ? "json" : this.#encoding;
18974
19010
  try {
18975
- return deserializeWithEncoding(
19011
+ const error46 = deserializeWithEncoding(
18976
19012
  encoding,
18977
19013
  new Uint8Array(await response.clone().arrayBuffer()),
18978
19014
  HTTP_RESPONSE_ERROR_VERSIONED,
@@ -18996,6 +19032,10 @@ var ActorHandleRaw = class {
18996
19032
  } : void 0
18997
19033
  })
18998
19034
  );
19035
+ return {
19036
+ ...error46,
19037
+ rayId: response.headers.get("x-rivet-ray-id") ?? void 0
19038
+ };
18999
19039
  } catch {
19000
19040
  return null;
19001
19041
  }
@@ -19059,7 +19099,9 @@ var ActorHandleRaw = class {
19059
19099
  "actor",
19060
19100
  "reload_failed",
19061
19101
  `reload failed with status ${response.status}: ${body}`,
19062
- {}
19102
+ {
19103
+ rayId: response.headers.get("x-rivet-ray-id") ?? void 0
19104
+ }
19063
19105
  );
19064
19106
  }
19065
19107
  }
@@ -19913,7 +19955,7 @@ var ActorConnRaw = class {
19913
19955
  const reason = closeEvent.reason || "";
19914
19956
  const parsed = parseWebSocketCloseReason(reason);
19915
19957
  if (parsed) {
19916
- const { group, code } = parsed;
19958
+ const { group, code, rayId } = parsed;
19917
19959
  if (this.#shouldReconnectForStaleActor(group, code)) {
19918
19960
  this.#clearResolvedActorIdentity();
19919
19961
  (_a2 = this.#onOpenPromise) == null ? void 0 : _a2.reject(
@@ -19921,7 +19963,7 @@ var ActorConnRaw = class {
19921
19963
  group,
19922
19964
  code,
19923
19965
  `Connection closed: ${reason}`,
19924
- void 0
19966
+ { rayId }
19925
19967
  )
19926
19968
  );
19927
19969
  return;
@@ -19932,7 +19974,8 @@ var ActorConnRaw = class {
19932
19974
  code,
19933
19975
  this.#actorId,
19934
19976
  this.#actorResolutionState,
19935
- this.#driver
19977
+ this.#driver,
19978
+ rayId
19936
19979
  );
19937
19980
  if (schedulingError) {
19938
19981
  error46 = schedulingError;
@@ -19941,7 +19984,7 @@ var ActorConnRaw = class {
19941
19984
  group,
19942
19985
  code,
19943
19986
  `Connection closed: ${reason}`,
19944
- void 0
19987
+ { rayId }
19945
19988
  );
19946
19989
  }
19947
19990
  } else {
@@ -19949,7 +19992,7 @@ var ActorConnRaw = class {
19949
19992
  group,
19950
19993
  code,
19951
19994
  `Connection closed: ${reason}`,
19952
- void 0
19995
+ { rayId }
19953
19996
  );
19954
19997
  }
19955
19998
  this.#invalidateActorIfStale(group, code);
@@ -21326,24 +21369,45 @@ var RemoteEngineControlClient = class {
21326
21369
  name,
21327
21370
  key
21328
21371
  });
21329
- const { actor: actor2, created } = await getOrCreateActor(this.#config, {
21330
- datacenter: region,
21331
- name,
21332
- key: serializeActorKey(key),
21333
- runner_name_selector: poolName ?? this.#config.poolName,
21334
- input: actorInput ? uint8ArrayToBase642(
21335
- encodeCborCompat(actorInput)
21336
- ) : void 0,
21337
- crash_policy: crashPolicy ?? "sleep"
21338
- });
21339
- logger2().info({
21340
- msg: "getOrCreateWithKey: actor ready",
21341
- actorId: actor2.actor_id,
21342
- name,
21343
- key,
21344
- created
21345
- });
21346
- return apiActorToOutput(actor2);
21372
+ try {
21373
+ const { actor: actor2, created } = await getOrCreateActor(this.#config, {
21374
+ datacenter: region,
21375
+ name,
21376
+ key: serializeActorKey(key),
21377
+ runner_name_selector: poolName ?? this.#config.poolName,
21378
+ input: actorInput ? uint8ArrayToBase642(
21379
+ encodeCborCompat(actorInput)
21380
+ ) : void 0,
21381
+ crash_policy: crashPolicy ?? "sleep"
21382
+ });
21383
+ logger2().info({
21384
+ msg: "getOrCreateWithKey: actor ready",
21385
+ actorId: actor2.actor_id,
21386
+ name,
21387
+ key,
21388
+ created
21389
+ });
21390
+ return apiActorToOutput(actor2);
21391
+ } catch (error46) {
21392
+ if (error46 instanceof RivetError && error46.group === "actor" && error46.code === "key_reserved_in_different_datacenter") {
21393
+ logger2().warn({
21394
+ msg: "getOrCreateWithKey: key reserved in different datacenter, retrying as get",
21395
+ name,
21396
+ key
21397
+ });
21398
+ const response = await getActorByKey(this.#config, name, key);
21399
+ const existing = response.actors[0];
21400
+ if (!existing) throw error46;
21401
+ logger2().info({
21402
+ msg: "getOrCreateWithKey: resolved existing actor via get",
21403
+ actorId: existing.actor_id,
21404
+ name,
21405
+ key
21406
+ });
21407
+ return apiActorToOutput(existing);
21408
+ }
21409
+ throw error46;
21410
+ }
21347
21411
  }
21348
21412
  async createActor({
21349
21413
  name,
@@ -21544,7 +21608,7 @@ function apiActorToOutput(actor2) {
21544
21608
  };
21545
21609
  }
21546
21610
 
21547
- // ../rivetkit/dist/tsup/chunk-KRPA4UOE.js
21611
+ // ../rivetkit/dist/tsup/chunk-PSXMESQJ.js
21548
21612
  var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
21549
21613
  var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
21550
21614
  function registerNativeStateTransactionOpener(provider, opener) {
@@ -26441,7 +26505,8 @@ function encodeNativeCallbackError(error46) {
26441
26505
  return Object.assign(bridgeError, {
26442
26506
  group: structuredError.group,
26443
26507
  code: structuredError.code,
26444
- metadata: structuredError.metadata
26508
+ metadata: structuredError.metadata,
26509
+ rayId: structuredError.rayId
26445
26510
  });
26446
26511
  }
26447
26512
  async function callNative(invoke) {
package/dist/mod.mjs CHANGED
@@ -297,13 +297,13 @@ var require_retry2 = __commonJS({
297
297
  // src/mod.ts
298
298
  import * as wasmBindings from "@rivetkit/rivetkit-wasm";
299
299
 
300
- // ../rivetkit/dist/tsup/chunk-ZZ3WBRPD.js
300
+ // ../rivetkit/dist/tsup/chunk-IXBD7BXC.js
301
301
  var INTERNAL_ERROR_CODE = "internal_error";
302
302
  var INTERNAL_ERROR_DESCRIPTION = "An internal error occurred";
303
303
  var USER_ERROR_CODE = "user_error";
304
304
  var BRIDGE_RIVET_ERROR_PREFIX = "__RIVET_ERROR_JSON__:";
305
305
  function looksLikeRivetErrorOptions(value) {
306
- return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "statusCode" in value || "actor" in value || "cause" in value);
306
+ return typeof value === "object" && value !== null && ("public" in value || "metadata" in value || "rayId" in value || "statusCode" in value || "actor" in value || "cause" in value);
307
307
  }
308
308
  function isTypedErrorTag(value) {
309
309
  return value === "ActorError" || value === "RivetError";
@@ -315,7 +315,7 @@ function errorMessage(error46, fallback = String(error46)) {
315
315
  return fallback;
316
316
  }
317
317
  function isRivetErrorLike(error46) {
318
- return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("__type" in error46) || isTypedErrorTag(error46.__type));
318
+ return typeof error46 === "object" && error46 !== null && "group" in error46 && typeof error46.group === "string" && "code" in error46 && typeof error46.code === "string" && "message" in error46 && typeof error46.message === "string" && (!("rayId" in error46) || error46.rayId === void 0 || typeof error46.rayId === "string") && (!("__type" in error46) || isTypedErrorTag(error46.__type));
319
319
  }
320
320
  function isActorAbortedError(error46) {
321
321
  return isRivetErrorLike(error46) && error46.group === "actor" && error46.code === "aborted";
@@ -327,6 +327,7 @@ var RivetError = class extends Error {
327
327
  __type = "RivetError";
328
328
  public;
329
329
  metadata;
330
+ rayId;
330
331
  statusCode;
331
332
  actor;
332
333
  group;
@@ -345,6 +346,7 @@ var RivetError = class extends Error {
345
346
  this.code = code;
346
347
  this.public = normalized.public ?? false;
347
348
  this.metadata = normalized.metadata;
349
+ this.rayId = normalized.rayId ?? void 0;
348
350
  this.statusCode = normalized.statusCode ?? (this.public ? 400 : 500);
349
351
  this.actor = normalized.actor;
350
352
  }
@@ -379,6 +381,7 @@ function toRivetError(error46, fallback) {
379
381
  public: error46.public,
380
382
  statusCode: error46.statusCode,
381
383
  metadata: error46.metadata,
384
+ rayId: error46.rayId,
382
385
  actor: error46.actor,
383
386
  cause: error46 instanceof Error ? error46.cause : void 0
384
387
  });
@@ -391,6 +394,7 @@ function toRivetError(error46, fallback) {
391
394
  public: fallback == null ? void 0 : fallback.public,
392
395
  statusCode: fallback == null ? void 0 : fallback.statusCode,
393
396
  metadata: fallback == null ? void 0 : fallback.metadata,
397
+ rayId: fallback == null ? void 0 : fallback.rayId,
394
398
  actor: fallback == null ? void 0 : fallback.actor,
395
399
  cause: error46 instanceof Error ? error46 : void 0
396
400
  }
@@ -402,6 +406,7 @@ function encodeBridgeRivetError(error46) {
402
406
  code: error46.code,
403
407
  message: error46.message,
404
408
  metadata: error46.metadata,
409
+ rayId: error46.rayId,
405
410
  public: error46.public,
406
411
  statusCode: error46.statusCode,
407
412
  actor: error46.actor
@@ -412,9 +417,13 @@ function decodeBridgeRivetErrorPayload(value) {
412
417
  return void 0;
413
418
  }
414
419
  try {
415
- const payload = JSON.parse(
420
+ const raw = JSON.parse(
416
421
  value.slice(BRIDGE_RIVET_ERROR_PREFIX.length)
417
422
  );
423
+ const payload = {
424
+ ...raw,
425
+ rayId: raw.rayId ?? void 0
426
+ };
418
427
  if (!isRivetErrorLike(payload)) {
419
428
  return void 0;
420
429
  }
@@ -433,6 +442,7 @@ function decodeBridgeRivetError(value) {
433
442
  }
434
443
  return new RivetError(payload.group, payload.code, payload.message, {
435
444
  metadata: payload.metadata,
445
+ rayId: payload.rayId,
436
446
  public: payload.public,
437
447
  statusCode: payload.statusCode,
438
448
  actor: payload.actor ?? void 0
@@ -471,7 +481,7 @@ function unsupportedFeature(feature) {
471
481
  );
472
482
  }
473
483
 
474
- // ../rivetkit/dist/tsup/chunk-HVHDZDM2.js
484
+ // ../rivetkit/dist/tsup/chunk-OLGQYFUW.js
475
485
  import {
476
486
  pino,
477
487
  stdTimeFunctions
@@ -13147,7 +13157,7 @@ var classic_default = external_exports;
13147
13157
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
13148
13158
  var v4_default = classic_default;
13149
13159
 
13150
- // ../rivetkit/dist/tsup/chunk-HVHDZDM2.js
13160
+ // ../rivetkit/dist/tsup/chunk-OLGQYFUW.js
13151
13161
  var import_invariant = __toESM(require_invariant(), 1);
13152
13162
  import * as cbor from "cbor-x";
13153
13163
  var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
@@ -13216,6 +13226,7 @@ function deconstructError(error46, exposeInternalError = false) {
13216
13226
  let code;
13217
13227
  let message;
13218
13228
  let metadata;
13229
+ let rayId;
13219
13230
  let actor2;
13220
13231
  if (isCanonicalStructuredRivetError(error46)) {
13221
13232
  statusCode = typeof error46.statusCode === "number" ? error46.statusCode : error46.public ? 400 : 500;
@@ -13224,6 +13235,7 @@ function deconstructError(error46, exposeInternalError = false) {
13224
13235
  code = error46.code;
13225
13236
  message = error46.message;
13226
13237
  metadata = error46.metadata;
13238
+ rayId = error46.rayId;
13227
13239
  actor2 = error46.actor;
13228
13240
  } else if (RivetError.isActorError(error46) && error46.public) {
13229
13241
  statusCode = "statusCode" in error46 && error46.statusCode ? error46.statusCode : 400;
@@ -13232,6 +13244,7 @@ function deconstructError(error46, exposeInternalError = false) {
13232
13244
  code = error46.code;
13233
13245
  message = getErrorMessage(error46);
13234
13246
  metadata = error46.metadata;
13247
+ rayId = error46.rayId;
13235
13248
  actor2 = error46.actor;
13236
13249
  } else if (exposeInternalError) {
13237
13250
  if (RivetError.isActorError(error46)) {
@@ -13241,6 +13254,7 @@ function deconstructError(error46, exposeInternalError = false) {
13241
13254
  code = error46.code;
13242
13255
  message = getErrorMessage(error46);
13243
13256
  metadata = error46.metadata;
13257
+ rayId = error46.rayId;
13244
13258
  actor2 = error46.actor;
13245
13259
  } else {
13246
13260
  statusCode = 500;
@@ -13270,6 +13284,7 @@ function deconstructError(error46, exposeInternalError = false) {
13270
13284
  code,
13271
13285
  message,
13272
13286
  metadata,
13287
+ rayId,
13273
13288
  actor: actor2
13274
13289
  };
13275
13290
  }
@@ -13312,7 +13327,7 @@ function noopNext() {
13312
13327
  }
13313
13328
  var package_default = {
13314
13329
  name: "rivetkit",
13315
- version: "2.3.12-rc.1",
13330
+ version: "2.3.12-rc.3",
13316
13331
  description: "Lightweight libraries for building stateful actors on edge platforms",
13317
13332
  license: "Apache-2.0",
13318
13333
  keywords: [
@@ -14615,7 +14630,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
14615
14630
  };
14616
14631
  }
14617
14632
 
14618
- // ../rivetkit/dist/tsup/chunk-5UYNV4W6.js
14633
+ // ../rivetkit/dist/tsup/chunk-WVFTFWJL.js
14619
14634
  var config2 = /* @__PURE__ */ Config({});
14620
14635
  function readWorkflowCbor(bc) {
14621
14636
  return readData(bc);
@@ -15577,7 +15592,7 @@ var AsyncMutex = class {
15577
15592
  }
15578
15593
  };
15579
15594
 
15580
- // ../rivetkit/dist/tsup/chunk-JHHAMABO.js
15595
+ // ../rivetkit/dist/tsup/chunk-XI4MEUUI.js
15581
15596
  function logger() {
15582
15597
  return getLogger("actor-client");
15583
15598
  }
@@ -15615,7 +15630,7 @@ async function importWebSocket() {
15615
15630
  return webSocketPromise;
15616
15631
  }
15617
15632
 
15618
- // ../rivetkit/dist/tsup/chunk-A5BZEQOG.js
15633
+ // ../rivetkit/dist/tsup/chunk-YYIDQBBM.js
15619
15634
  var import_invariant2 = __toESM(require_invariant(), 1);
15620
15635
 
15621
15636
  // ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
@@ -15793,7 +15808,7 @@ function createVersionedDataHandler(config3) {
15793
15808
  return new VersionedDataHandler(config3);
15794
15809
  }
15795
15810
 
15796
- // ../rivetkit/dist/tsup/chunk-A5BZEQOG.js
15811
+ // ../rivetkit/dist/tsup/chunk-YYIDQBBM.js
15797
15812
  var import_invariant3 = __toESM(require_invariant(), 1);
15798
15813
  var import_invariant4 = __toESM(require_invariant(), 1);
15799
15814
  var PATH_CONNECT = "/connect";
@@ -15848,12 +15863,12 @@ var ActorConnDisposed = class extends ActorClientError {
15848
15863
  function isSchedulingError(group, code) {
15849
15864
  return group === "guard" && (code === "actor_ready_timeout" || code === "actor_runner_failed");
15850
15865
  }
15851
- function actorSchedulingError(group, code, actorId, details) {
15866
+ function actorSchedulingError(group, code, actorId, details, rayId) {
15852
15867
  return new RivetError(
15853
15868
  group,
15854
15869
  code,
15855
15870
  `Actor failed to start (${actorId}): ${JSON.stringify(details)}`,
15856
- { metadata: { actorId, details } }
15871
+ { metadata: { actorId, details }, rayId }
15857
15872
  );
15858
15873
  }
15859
15874
  function internalClientError(message, opts) {
@@ -17833,7 +17848,7 @@ function getGatewayTarget(state) {
17833
17848
  function isStaleResolvedActorError(group, code) {
17834
17849
  return group === "actor" && (code === "not_found" || code === "starting" || code === "stopping" || code === "not_configured" || code === "dropped_reply" || code.startsWith("destroyed_"));
17835
17850
  }
17836
- async function checkForSchedulingError(group, code, actorId, query, driver) {
17851
+ async function checkForSchedulingError(group, code, actorId, query, driver, rayId) {
17837
17852
  const name = getActorNameFromQuery(query);
17838
17853
  try {
17839
17854
  const actor2 = await driver.getForId({ name, actorId });
@@ -17843,7 +17858,13 @@ async function checkForSchedulingError(group, code, actorId, query, driver) {
17843
17858
  actorId,
17844
17859
  error: actor2.error
17845
17860
  });
17846
- return actorSchedulingError(group, code, actorId, actor2.error);
17861
+ return actorSchedulingError(
17862
+ group,
17863
+ code,
17864
+ actorId,
17865
+ actor2.error,
17866
+ rayId
17867
+ );
17847
17868
  }
17848
17869
  } catch (err) {
17849
17870
  logger().warn({
@@ -18160,6 +18181,7 @@ async function sendHttpRequest(opts) {
18160
18181
  code: responseData.code,
18161
18182
  message: responseData.message,
18162
18183
  metadata: responseData.metadata,
18184
+ rayId,
18163
18185
  actorId: (_a2 = responseData.actor) == null ? void 0 : _a2.actorId,
18164
18186
  generation: (_b = responseData.actor) == null ? void 0 : _b.generation,
18165
18187
  actorKey: (_c = responseData.actor) == null ? void 0 : _c.key
@@ -18170,6 +18192,7 @@ async function sendHttpRequest(opts) {
18170
18192
  responseData.message,
18171
18193
  {
18172
18194
  metadata: responseData.metadata,
18195
+ rayId: rayId ?? void 0,
18173
18196
  actor: responseData.actor
18174
18197
  }
18175
18198
  );
@@ -18349,11 +18372,8 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}) {
18349
18372
  });
18350
18373
  return driver.sendRequest(target, proxyRequest, options);
18351
18374
  } catch (err) {
18352
- const { group, code, message, metadata, actor: actor2 } = deconstructError(
18353
- err,
18354
- true
18355
- );
18356
- throw new RivetError(group, code, message, { metadata, actor: actor2 });
18375
+ const { group, code, message, metadata, rayId, actor: actor2 } = deconstructError(err, true);
18376
+ throw new RivetError(group, code, message, { metadata, rayId, actor: actor2 });
18357
18377
  }
18358
18378
  }
18359
18379
  async function rawWebSocket(driver, target, params, path2, _protocols, options = {}) {
@@ -18468,7 +18488,7 @@ var ActorHandleRaw = class {
18468
18488
  async #sendQueueMessage(name, body, options) {
18469
18489
  return await this.#queueSendMutex.run(async () => {
18470
18490
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
18471
- let useQueryTarget = false;
18491
+ let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
18472
18492
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
18473
18493
  let actorId;
18474
18494
  try {
@@ -18492,7 +18512,7 @@ var ActorHandleRaw = class {
18492
18512
  }
18493
18513
  }).send(name, body, options);
18494
18514
  } catch (err) {
18495
- const { group, code, message, metadata, actor: actor2 } = deconstructError(err, true);
18515
+ const { group, code, message, metadata, rayId, actor: actor2 } = deconstructError(err, true);
18496
18516
  if (this.#shouldRetryQueueDispatchOverload(
18497
18517
  group,
18498
18518
  code,
@@ -18508,7 +18528,8 @@ var ActorHandleRaw = class {
18508
18528
  code,
18509
18529
  actorId,
18510
18530
  attempt,
18511
- maxAttempts
18531
+ maxAttempts,
18532
+ rayId
18512
18533
  )) {
18513
18534
  useQueryTarget = true;
18514
18535
  await this.#waitForRetryWindow();
@@ -18530,14 +18551,16 @@ var ActorHandleRaw = class {
18530
18551
  code
18531
18552
  );
18532
18553
  if (invalidated && attempt < maxAttempts - 1) {
18533
- useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18534
- if (useQueryTarget) {
18554
+ const waitForReady = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18555
+ useQueryTarget = useQueryTarget || waitForReady;
18556
+ if (waitForReady) {
18535
18557
  await this.#waitForRetryWindow();
18536
18558
  }
18537
18559
  continue;
18538
18560
  }
18539
18561
  throw new RivetError(group, code, message, {
18540
18562
  metadata,
18563
+ rayId,
18541
18564
  actor: actor2
18542
18565
  });
18543
18566
  }
@@ -18566,7 +18589,7 @@ var ActorHandleRaw = class {
18566
18589
  }
18567
18590
  async #sendActionNow(opts) {
18568
18591
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
18569
- let useQueryTarget = false;
18592
+ let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
18570
18593
  const gatewayOptions = resolveActorGatewayOptions(
18571
18594
  this.#gatewayOptions,
18572
18595
  opts
@@ -18631,13 +18654,14 @@ var ActorHandleRaw = class {
18631
18654
  }
18632
18655
  return output;
18633
18656
  } catch (err) {
18634
- const { group, code, message, metadata, actor: actor2 } = deconstructError(err, true);
18657
+ const { group, code, message, metadata, rayId, actor: actor2 } = deconstructError(err, true);
18635
18658
  if (await this.#shouldRetrySchedulingError(
18636
18659
  group,
18637
18660
  code,
18638
18661
  actorId,
18639
18662
  attempt,
18640
- maxAttempts
18663
+ maxAttempts,
18664
+ rayId
18641
18665
  )) {
18642
18666
  useQueryTarget = true;
18643
18667
  await this.#waitForRetryWindow();
@@ -18659,7 +18683,7 @@ var ActorHandleRaw = class {
18659
18683
  "actor",
18660
18684
  "not_found",
18661
18685
  "The actor does not exist or was destroyed.",
18662
- { metadata, actor: actor2 }
18686
+ { metadata, rayId, actor: actor2 }
18663
18687
  );
18664
18688
  }
18665
18689
  const invalidated = this.#invalidateResolvedActorId(
@@ -18675,7 +18699,11 @@ var ActorHandleRaw = class {
18675
18699
  }
18676
18700
  continue;
18677
18701
  }
18678
- throw new RivetError(group, code, message, { metadata, actor: actor2 });
18702
+ throw new RivetError(group, code, message, {
18703
+ metadata,
18704
+ rayId,
18705
+ actor: actor2
18706
+ });
18679
18707
  }
18680
18708
  }
18681
18709
  throw new Error("unreachable action retry state");
@@ -18717,7 +18745,7 @@ var ActorHandleRaw = class {
18717
18745
  this.#resolvedActorId = void 0;
18718
18746
  this.#resolvingActorId = void 0;
18719
18747
  }
18720
- async #shouldRetrySchedulingError(group, code, actorId, attempt, maxAttempts) {
18748
+ async #shouldRetrySchedulingError(group, code, actorId, attempt, maxAttempts, rayId) {
18721
18749
  if (!isDynamicActorQuery(this.#actorResolutionState) || !isSchedulingError(group, code) || attempt >= maxAttempts - 1) {
18722
18750
  return false;
18723
18751
  }
@@ -18727,7 +18755,8 @@ var ActorHandleRaw = class {
18727
18755
  code,
18728
18756
  actorId,
18729
18757
  this.#actorResolutionState,
18730
- this.#driver
18758
+ this.#driver,
18759
+ rayId
18731
18760
  );
18732
18761
  if (schedulingError) {
18733
18762
  throw schedulingError;
@@ -18809,7 +18838,7 @@ var ActorHandleRaw = class {
18809
18838
  }
18810
18839
  async #fetchWithResolvedActor(input, init) {
18811
18840
  const maxAttempts = this.#getDynamicQueryMaxAttempts();
18812
- let useQueryTarget = false;
18841
+ let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
18813
18842
  const { skipReadyWait, ...requestInit } = init ?? {};
18814
18843
  const gatewayOptions = resolveActorGatewayOptions(
18815
18844
  this.#gatewayOptions,
@@ -18848,13 +18877,14 @@ var ActorHandleRaw = class {
18848
18877
  }
18849
18878
  return response;
18850
18879
  } catch (err) {
18851
- const { group, code, message, metadata, actor: actor2 } = deconstructError(err, true);
18880
+ const { group, code, message, metadata, rayId, actor: actor2 } = deconstructError(err, true);
18852
18881
  if (await this.#shouldRetrySchedulingError(
18853
18882
  group,
18854
18883
  code,
18855
18884
  actorId,
18856
18885
  attempt,
18857
- maxAttempts
18886
+ maxAttempts,
18887
+ rayId
18858
18888
  )) {
18859
18889
  useQueryTarget = true;
18860
18890
  await this.#waitForRetryWindow();
@@ -18876,13 +18906,18 @@ var ActorHandleRaw = class {
18876
18906
  code
18877
18907
  );
18878
18908
  if (invalidated && attempt < maxAttempts - 1) {
18879
- useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18880
- if (useQueryTarget) {
18909
+ const waitForReady = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18910
+ useQueryTarget = useQueryTarget || waitForReady;
18911
+ if (waitForReady) {
18881
18912
  await this.#waitForRetryWindow();
18882
18913
  }
18883
18914
  continue;
18884
18915
  }
18885
- throw new RivetError(group, code, message, { metadata, actor: actor2 });
18916
+ throw new RivetError(group, code, message, {
18917
+ metadata,
18918
+ rayId,
18919
+ actor: actor2
18920
+ });
18886
18921
  }
18887
18922
  }
18888
18923
  throw new Error("unreachable fetch retry state");
@@ -18895,13 +18930,14 @@ var ActorHandleRaw = class {
18895
18930
  if (!error46) {
18896
18931
  return null;
18897
18932
  }
18898
- const { group, code } = error46;
18933
+ const { group, code, rayId } = error46;
18899
18934
  if (await this.#shouldRetrySchedulingError(
18900
18935
  group,
18901
18936
  code,
18902
18937
  actorId,
18903
18938
  attempt,
18904
- maxAttempts
18939
+ maxAttempts,
18940
+ rayId
18905
18941
  )) {
18906
18942
  return {
18907
18943
  useQueryTarget: true,
@@ -18922,10 +18958,10 @@ var ActorHandleRaw = class {
18922
18958
  }
18923
18959
  const invalidated = this.#invalidateResolvedActorId(group, code);
18924
18960
  if (invalidated && attempt < maxAttempts - 1) {
18925
- const useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18961
+ const waitForReady = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
18926
18962
  return {
18927
- useQueryTarget,
18928
- waitForRetryWindow: useQueryTarget
18963
+ useQueryTarget: true,
18964
+ waitForRetryWindow: waitForReady
18929
18965
  };
18930
18966
  }
18931
18967
  return null;
@@ -18937,7 +18973,7 @@ var ActorHandleRaw = class {
18937
18973
  const contentType = response.headers.get("content-type");
18938
18974
  const encoding = (contentType == null ? void 0 : contentType.includes("application/json")) ? "json" : this.#encoding;
18939
18975
  try {
18940
- return deserializeWithEncoding(
18976
+ const error46 = deserializeWithEncoding(
18941
18977
  encoding,
18942
18978
  new Uint8Array(await response.clone().arrayBuffer()),
18943
18979
  HTTP_RESPONSE_ERROR_VERSIONED,
@@ -18961,6 +18997,10 @@ var ActorHandleRaw = class {
18961
18997
  } : void 0
18962
18998
  })
18963
18999
  );
19000
+ return {
19001
+ ...error46,
19002
+ rayId: response.headers.get("x-rivet-ray-id") ?? void 0
19003
+ };
18964
19004
  } catch {
18965
19005
  return null;
18966
19006
  }
@@ -19024,7 +19064,9 @@ var ActorHandleRaw = class {
19024
19064
  "actor",
19025
19065
  "reload_failed",
19026
19066
  `reload failed with status ${response.status}: ${body}`,
19027
- {}
19067
+ {
19068
+ rayId: response.headers.get("x-rivet-ray-id") ?? void 0
19069
+ }
19028
19070
  );
19029
19071
  }
19030
19072
  }
@@ -19878,7 +19920,7 @@ var ActorConnRaw = class {
19878
19920
  const reason = closeEvent.reason || "";
19879
19921
  const parsed = parseWebSocketCloseReason(reason);
19880
19922
  if (parsed) {
19881
- const { group, code } = parsed;
19923
+ const { group, code, rayId } = parsed;
19882
19924
  if (this.#shouldReconnectForStaleActor(group, code)) {
19883
19925
  this.#clearResolvedActorIdentity();
19884
19926
  (_a2 = this.#onOpenPromise) == null ? void 0 : _a2.reject(
@@ -19886,7 +19928,7 @@ var ActorConnRaw = class {
19886
19928
  group,
19887
19929
  code,
19888
19930
  `Connection closed: ${reason}`,
19889
- void 0
19931
+ { rayId }
19890
19932
  )
19891
19933
  );
19892
19934
  return;
@@ -19897,7 +19939,8 @@ var ActorConnRaw = class {
19897
19939
  code,
19898
19940
  this.#actorId,
19899
19941
  this.#actorResolutionState,
19900
- this.#driver
19942
+ this.#driver,
19943
+ rayId
19901
19944
  );
19902
19945
  if (schedulingError) {
19903
19946
  error46 = schedulingError;
@@ -19906,7 +19949,7 @@ var ActorConnRaw = class {
19906
19949
  group,
19907
19950
  code,
19908
19951
  `Connection closed: ${reason}`,
19909
- void 0
19952
+ { rayId }
19910
19953
  );
19911
19954
  }
19912
19955
  } else {
@@ -19914,7 +19957,7 @@ var ActorConnRaw = class {
19914
19957
  group,
19915
19958
  code,
19916
19959
  `Connection closed: ${reason}`,
19917
- void 0
19960
+ { rayId }
19918
19961
  );
19919
19962
  }
19920
19963
  this.#invalidateActorIfStale(group, code);
@@ -21291,24 +21334,45 @@ var RemoteEngineControlClient = class {
21291
21334
  name,
21292
21335
  key
21293
21336
  });
21294
- const { actor: actor2, created } = await getOrCreateActor(this.#config, {
21295
- datacenter: region,
21296
- name,
21297
- key: serializeActorKey(key),
21298
- runner_name_selector: poolName ?? this.#config.poolName,
21299
- input: actorInput ? uint8ArrayToBase642(
21300
- encodeCborCompat(actorInput)
21301
- ) : void 0,
21302
- crash_policy: crashPolicy ?? "sleep"
21303
- });
21304
- logger2().info({
21305
- msg: "getOrCreateWithKey: actor ready",
21306
- actorId: actor2.actor_id,
21307
- name,
21308
- key,
21309
- created
21310
- });
21311
- return apiActorToOutput(actor2);
21337
+ try {
21338
+ const { actor: actor2, created } = await getOrCreateActor(this.#config, {
21339
+ datacenter: region,
21340
+ name,
21341
+ key: serializeActorKey(key),
21342
+ runner_name_selector: poolName ?? this.#config.poolName,
21343
+ input: actorInput ? uint8ArrayToBase642(
21344
+ encodeCborCompat(actorInput)
21345
+ ) : void 0,
21346
+ crash_policy: crashPolicy ?? "sleep"
21347
+ });
21348
+ logger2().info({
21349
+ msg: "getOrCreateWithKey: actor ready",
21350
+ actorId: actor2.actor_id,
21351
+ name,
21352
+ key,
21353
+ created
21354
+ });
21355
+ return apiActorToOutput(actor2);
21356
+ } catch (error46) {
21357
+ if (error46 instanceof RivetError && error46.group === "actor" && error46.code === "key_reserved_in_different_datacenter") {
21358
+ logger2().warn({
21359
+ msg: "getOrCreateWithKey: key reserved in different datacenter, retrying as get",
21360
+ name,
21361
+ key
21362
+ });
21363
+ const response = await getActorByKey(this.#config, name, key);
21364
+ const existing = response.actors[0];
21365
+ if (!existing) throw error46;
21366
+ logger2().info({
21367
+ msg: "getOrCreateWithKey: resolved existing actor via get",
21368
+ actorId: existing.actor_id,
21369
+ name,
21370
+ key
21371
+ });
21372
+ return apiActorToOutput(existing);
21373
+ }
21374
+ throw error46;
21375
+ }
21312
21376
  }
21313
21377
  async createActor({
21314
21378
  name,
@@ -21509,7 +21573,7 @@ function apiActorToOutput(actor2) {
21509
21573
  };
21510
21574
  }
21511
21575
 
21512
- // ../rivetkit/dist/tsup/chunk-KRPA4UOE.js
21576
+ // ../rivetkit/dist/tsup/chunk-PSXMESQJ.js
21513
21577
  var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
21514
21578
  var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
21515
21579
  function registerNativeStateTransactionOpener(provider, opener) {
@@ -26406,7 +26470,8 @@ function encodeNativeCallbackError(error46) {
26406
26470
  return Object.assign(bridgeError, {
26407
26471
  group: structuredError.group,
26408
26472
  code: structuredError.code,
26409
- metadata: structuredError.metadata
26473
+ metadata: structuredError.metadata,
26474
+ rayId: structuredError.rayId
26410
26475
  });
26411
26476
  }
26412
26477
  async function callNative(invoke) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivetkit/supabase",
3
- "version": "2.3.12-rc.1",
3
+ "version": "2.3.12-rc.3",
4
4
  "description": "Supabase Edge Functions integration for RivetKit actors",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -39,14 +39,14 @@
39
39
  "check-edge-closure": "node ../../../scripts/ci/check-edge-native-closure.mjs"
40
40
  },
41
41
  "dependencies": {
42
- "@rivetkit/rivetkit-wasm": "2.3.12-rc.1",
42
+ "@rivetkit/rivetkit-wasm": "2.3.12-rc.3",
43
43
  "cbor-x": "^1.6.0",
44
44
  "pino": "^9.5.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@size-limit/file": "^11.1.6",
48
48
  "@types/node": "^22.0.0",
49
- "rivetkit": "2.3.12-rc.1",
49
+ "rivetkit": "2.3.12-rc.3",
50
50
  "size-limit": "^11.1.6",
51
51
  "tsup": "^8.4.0",
52
52
  "typescript": "^5.5.2"