rivetkit 2.3.18 → 2.3.20

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 (140) hide show
  1. package/dist/browser/client.d.ts +754 -608
  2. package/dist/browser/client.js +184 -28
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +3 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/actor/errors.cjs +6 -2
  7. package/dist/tsup/actor/errors.cjs.map +1 -1
  8. package/dist/tsup/actor/errors.d.cts +1 -1
  9. package/dist/tsup/actor/errors.d.ts +1 -1
  10. package/dist/tsup/actor/errors.js +5 -1
  11. package/dist/tsup/agent-os/index.cjs +36 -1
  12. package/dist/tsup/agent-os/index.cjs.map +1 -1
  13. package/dist/tsup/agent-os/index.d.cts +149 -3
  14. package/dist/tsup/agent-os/index.d.ts +149 -3
  15. package/dist/tsup/agent-os/index.js +36 -1
  16. package/dist/tsup/agent-os/index.js.map +1 -1
  17. package/dist/tsup/{chunk-2IDK6NX3.cjs → chunk-2CE5UNWK.cjs} +13 -13
  18. package/dist/tsup/chunk-2CE5UNWK.cjs.map +1 -0
  19. package/dist/tsup/{chunk-IPXIZSE7.js → chunk-2NXLTFWI.js} +3 -3
  20. package/dist/tsup/{chunk-OKVVWOC3.cjs → chunk-3WS7Z64U.cjs} +3 -3
  21. package/dist/tsup/{chunk-OKVVWOC3.cjs.map → chunk-3WS7Z64U.cjs.map} +1 -1
  22. package/dist/tsup/{chunk-LAITPJRA.js → chunk-553CIQJY.js} +2 -2
  23. package/dist/tsup/{chunk-PXKNBNVU.js → chunk-5G2J26VM.js} +188 -31
  24. package/dist/tsup/chunk-5G2J26VM.js.map +1 -0
  25. package/dist/tsup/{chunk-IKZ6DJMP.cjs → chunk-76YTS32R.cjs} +4 -4
  26. package/dist/tsup/{chunk-IKZ6DJMP.cjs.map → chunk-76YTS32R.cjs.map} +1 -1
  27. package/dist/tsup/{chunk-NRIRV3Z2.cjs → chunk-A36FMKOV.cjs} +352 -195
  28. package/dist/tsup/chunk-A36FMKOV.cjs.map +1 -0
  29. package/dist/tsup/{chunk-6W5VGLFT.js → chunk-CSOHAAZK.js} +33 -1
  30. package/dist/tsup/chunk-CSOHAAZK.js.map +1 -0
  31. package/dist/tsup/{chunk-T6JUXRNI.cjs → chunk-CVLNRT7O.cjs} +3 -3
  32. package/dist/tsup/{chunk-T6JUXRNI.cjs.map → chunk-CVLNRT7O.cjs.map} +1 -1
  33. package/dist/tsup/{chunk-7EPLADKM.js → chunk-DHWZTUKA.js} +7 -7
  34. package/dist/tsup/chunk-DHWZTUKA.js.map +1 -0
  35. package/dist/tsup/{chunk-4XECVATQ.js → chunk-DMQUERRN.js} +2 -2
  36. package/dist/tsup/{chunk-25Z2RK7C.cjs → chunk-IHKDFKM4.cjs} +3 -3
  37. package/dist/tsup/{chunk-25Z2RK7C.cjs.map → chunk-IHKDFKM4.cjs.map} +1 -1
  38. package/dist/tsup/{chunk-2JSYYH6P.cjs → chunk-JX2ITWAV.cjs} +13 -2
  39. package/dist/tsup/chunk-JX2ITWAV.cjs.map +1 -0
  40. package/dist/tsup/{chunk-4KGXFC6M.cjs → chunk-NWCAIWHL.cjs} +34 -2
  41. package/dist/tsup/chunk-NWCAIWHL.cjs.map +1 -0
  42. package/dist/tsup/{chunk-OUQUIBVW.js → chunk-P2OFXH4G.js} +12 -1
  43. package/dist/tsup/chunk-P2OFXH4G.js.map +1 -0
  44. package/dist/tsup/{chunk-ZRTESY7V.cjs → chunk-RSIOGT2U.cjs} +7 -7
  45. package/dist/tsup/{chunk-ZRTESY7V.cjs.map → chunk-RSIOGT2U.cjs.map} +1 -1
  46. package/dist/tsup/{chunk-QIFZELUQ.js → chunk-SNNVRHLX.js} +2 -2
  47. package/dist/tsup/{chunk-2MK75JFR.js → chunk-TZVAVPGJ.js} +4 -4
  48. package/dist/tsup/{chunk-TNSLNSQH.js → chunk-W2PXGWMR.js} +2 -2
  49. package/dist/tsup/{chunk-O7RSU3UC.cjs → chunk-WAISW7KR.cjs} +10 -10
  50. package/dist/tsup/{chunk-O7RSU3UC.cjs.map → chunk-WAISW7KR.cjs.map} +1 -1
  51. package/dist/tsup/client/mod.cjs +6 -6
  52. package/dist/tsup/client/mod.d.cts +5 -5
  53. package/dist/tsup/client/mod.d.ts +5 -5
  54. package/dist/tsup/client/mod.js +5 -5
  55. package/dist/tsup/common/log.cjs +3 -3
  56. package/dist/tsup/common/log.js +2 -2
  57. package/dist/tsup/common/websocket.cjs +4 -4
  58. package/dist/tsup/common/websocket.js +3 -3
  59. package/dist/tsup/{config-Ug5M2MOr.d.ts → config-Be-VOHaX.d.ts} +155 -11
  60. package/dist/tsup/{config-gvHwMas-.d.cts → config-Ct5uXxXk.d.cts} +155 -11
  61. package/dist/tsup/{context-DererUCI.d.ts → context-CXLa0BIM.d.ts} +1 -1
  62. package/dist/tsup/{context-BSCBvbfM.d.cts → context-Cw-11Q-B.d.cts} +1 -1
  63. package/dist/tsup/db/drizzle.cjs +3 -3
  64. package/dist/tsup/db/drizzle.js +2 -2
  65. package/dist/tsup/db/mod.cjs +4 -4
  66. package/dist/tsup/db/mod.js +3 -3
  67. package/dist/tsup/dynamic/mod.cjs +2 -2
  68. package/dist/tsup/dynamic/mod.d.cts +3 -3
  69. package/dist/tsup/dynamic/mod.d.ts +3 -3
  70. package/dist/tsup/dynamic/mod.js +1 -1
  71. package/dist/tsup/inspector/mod.cjs +6 -6
  72. package/dist/tsup/inspector/mod.js +5 -5
  73. package/dist/tsup/inspector/workflow.cjs +5 -5
  74. package/dist/tsup/inspector/workflow.js +4 -4
  75. package/dist/tsup/inspector-tab/mod.cjs +2 -2
  76. package/dist/tsup/inspector-tab/mod.d.cts +4 -4
  77. package/dist/tsup/inspector-tab/mod.d.ts +4 -4
  78. package/dist/tsup/inspector-tab/mod.js +1 -1
  79. package/dist/tsup/mod.cjs +506 -319
  80. package/dist/tsup/mod.cjs.map +1 -1
  81. package/dist/tsup/mod.d.cts +5 -5
  82. package/dist/tsup/mod.d.ts +5 -5
  83. package/dist/tsup/mod.js +381 -194
  84. package/dist/tsup/mod.js.map +1 -1
  85. package/dist/tsup/test/mod.cjs +7 -7
  86. package/dist/tsup/test/mod.d.cts +3 -3
  87. package/dist/tsup/test/mod.d.ts +3 -3
  88. package/dist/tsup/test/mod.js +5 -5
  89. package/dist/tsup/{utils-Bbz-3411.d.cts → utils-CNFeS-Dk.d.cts} +1 -1
  90. package/dist/tsup/{utils-vvJQyygr.d.ts → utils-DsoDinPz.d.cts} +9 -1
  91. package/dist/tsup/{utils-vvJQyygr.d.cts → utils-DsoDinPz.d.ts} +9 -1
  92. package/dist/tsup/{utils-BqdWVlzm.d.ts → utils-OQHBjfcM.d.ts} +1 -1
  93. package/dist/tsup/utils.cjs +3 -3
  94. package/dist/tsup/utils.d.cts +2 -2
  95. package/dist/tsup/utils.d.ts +2 -2
  96. package/dist/tsup/utils.js +2 -2
  97. package/dist/tsup/workflow/mod.cjs +33 -27
  98. package/dist/tsup/workflow/mod.cjs.map +1 -1
  99. package/dist/tsup/workflow/mod.d.cts +5 -5
  100. package/dist/tsup/workflow/mod.d.ts +5 -5
  101. package/dist/tsup/workflow/mod.js +25 -19
  102. package/dist/tsup/workflow/mod.js.map +1 -1
  103. package/package.json +10 -8
  104. package/src/actor/actions.ts +36 -0
  105. package/src/actor/config.ts +65 -0
  106. package/src/actor/definition.ts +6 -1
  107. package/src/actor/errors.ts +31 -0
  108. package/src/actor/mod.ts +5 -0
  109. package/src/actor/tracing.ts +28 -0
  110. package/src/client/actor-conn.ts +7 -0
  111. package/src/client/actor-handle.ts +57 -17
  112. package/src/client/client.ts +26 -6
  113. package/src/client/outbound-telemetry.ts +66 -0
  114. package/src/client/queue.ts +3 -0
  115. package/src/client/raw-utils.ts +3 -0
  116. package/src/common/actor-router-consts.ts +3 -0
  117. package/src/common/actor-telemetry-context.ts +19 -0
  118. package/src/common/otel-context.ts +99 -0
  119. package/src/common/utils.ts +1 -19
  120. package/src/engine-client/actor-http-client.ts +15 -0
  121. package/src/registry/index.ts +6 -0
  122. package/src/registry/napi-runtime.ts +155 -35
  123. package/src/registry/native.ts +295 -191
  124. package/src/registry/runtime.ts +74 -0
  125. package/src/registry/wasm-runtime.ts +40 -0
  126. package/src/workflow/driver.ts +20 -12
  127. package/dist/tsup/chunk-2IDK6NX3.cjs.map +0 -1
  128. package/dist/tsup/chunk-2JSYYH6P.cjs.map +0 -1
  129. package/dist/tsup/chunk-4KGXFC6M.cjs.map +0 -1
  130. package/dist/tsup/chunk-6W5VGLFT.js.map +0 -1
  131. package/dist/tsup/chunk-7EPLADKM.js.map +0 -1
  132. package/dist/tsup/chunk-NRIRV3Z2.cjs.map +0 -1
  133. package/dist/tsup/chunk-OUQUIBVW.js.map +0 -1
  134. package/dist/tsup/chunk-PXKNBNVU.js.map +0 -1
  135. /package/dist/tsup/{chunk-IPXIZSE7.js.map → chunk-2NXLTFWI.js.map} +0 -0
  136. /package/dist/tsup/{chunk-LAITPJRA.js.map → chunk-553CIQJY.js.map} +0 -0
  137. /package/dist/tsup/{chunk-4XECVATQ.js.map → chunk-DMQUERRN.js.map} +0 -0
  138. /package/dist/tsup/{chunk-QIFZELUQ.js.map → chunk-SNNVRHLX.js.map} +0 -0
  139. /package/dist/tsup/{chunk-2MK75JFR.js.map → chunk-TZVAVPGJ.js.map} +0 -0
  140. /package/dist/tsup/{chunk-TNSLNSQH.js.map → chunk-W2PXGWMR.js.map} +0 -0
package/dist/tsup/mod.js CHANGED
@@ -1,6 +1,3 @@
1
- import {
2
- decodeWorkflowHistoryTransport
3
- } from "./chunk-QIFZELUQ.js";
4
1
  import {
5
2
  ACTOR_CONTEXT_INTERNAL_SYMBOL,
6
3
  ActorConfigSchema,
@@ -11,12 +8,16 @@ import {
11
8
  disposeRunInspector,
12
9
  flattenActionHandlers,
13
10
  flattenActionInputSchemas,
11
+ flattenActionTraceSamplers,
14
12
  getRunFunction,
15
13
  getRunInspectorConfig,
16
14
  getRunInspectorKind,
17
15
  getRunMetadata,
18
16
  hasRunInspectorConfig
19
- } from "./chunk-6W5VGLFT.js";
17
+ } from "./chunk-CSOHAAZK.js";
18
+ import {
19
+ decodeWorkflowHistoryTransport
20
+ } from "./chunk-SNNVRHLX.js";
20
21
  import {
21
22
  ALLOWED_PUBLIC_HEADERS,
22
23
  HEADER_CONN_PARAMS,
@@ -26,20 +27,22 @@ import {
26
27
  createClientWithDriver,
27
28
  getDatacenters,
28
29
  isResponseLike,
30
+ readActiveTraceHeaders,
31
+ runWithActorInvocationSpan,
29
32
  tryParseEndpoint,
30
33
  updateRunnerConfig
31
- } from "./chunk-PXKNBNVU.js";
34
+ } from "./chunk-5G2J26VM.js";
32
35
  import {
33
36
  makePrefixedKey,
34
37
  removePrefixFromKey
35
38
  } from "./chunk-JI6GZ2C2.js";
39
+ import "./chunk-553CIQJY.js";
36
40
  import {
37
41
  bindNativeStateTransactionContext,
38
42
  db,
39
43
  registerNativeStateTransactionOpener
40
- } from "./chunk-TNSLNSQH.js";
44
+ } from "./chunk-W2PXGWMR.js";
41
45
  import "./chunk-JTHHCZCZ.js";
42
- import "./chunk-LAITPJRA.js";
43
46
  import {
44
47
  LogLevelSchema,
45
48
  VERSION,
@@ -73,19 +76,20 @@ import {
73
76
  parsePortEnv,
74
77
  stringifyError,
75
78
  toUint8Array
76
- } from "./chunk-7EPLADKM.js";
79
+ } from "./chunk-DHWZTUKA.js";
77
80
  import {
78
81
  INTERNAL_ERROR_CODE,
79
82
  RivetError,
80
83
  UserError,
81
84
  decodeBridgeRivetError,
82
85
  encodeBridgeRivetError,
86
+ encodeErrorForBridge,
83
87
  forbiddenError,
84
88
  isActorAbortedError,
85
89
  isRivetErrorLike,
86
90
  toRivetError,
87
91
  unsupportedFeature
88
- } from "./chunk-OUQUIBVW.js";
92
+ } from "./chunk-P2OFXH4G.js";
89
93
 
90
94
  // src/actor/log.ts
91
95
  function loggerWithoutContext() {
@@ -125,12 +129,14 @@ function isStaticActorInstance(_actor) {
125
129
  return true;
126
130
  }
127
131
  function actor(input) {
132
+ var _a;
128
133
  warnDeprecatedOptionKeys(
129
134
  input == null ? void 0 : input.options
130
135
  );
131
136
  const config = ActorConfigSchema.parse(input);
132
137
  flattenActionHandlers(config.actions);
133
138
  flattenActionInputSchemas(config.actions, config.actionInputSchemas);
139
+ flattenActionTraceSamplers(config.actions, (_a = config.tracing) == null ? void 0 : _a.actions);
134
140
  return new ActorDefinition(config);
135
141
  }
136
142
  function isStaticActorDefinition(definition) {
@@ -1545,20 +1551,43 @@ function toNapiQueueMessage(message) {
1545
1551
  var NapiCoreRuntime = class {
1546
1552
  kind = "napi";
1547
1553
  #bindings;
1548
- #sql = /* @__PURE__ */ new WeakMap();
1549
- constructor(bindings) {
1554
+ #sqlOpened = /* @__PURE__ */ new WeakSet();
1555
+ #invocationContext;
1556
+ constructor(bindings, invocationContext) {
1550
1557
  this.#bindings = bindings;
1558
+ this.#invocationContext = invocationContext;
1551
1559
  }
1552
- #actorSql(ctx) {
1553
- const nativeCtx = asNativeActorContext(ctx);
1554
- let database = this.#sql.get(nativeCtx);
1555
- if (!database) {
1556
- database = nativeCtx.sql();
1557
- this.#sql.set(nativeCtx, database);
1560
+ #actorContextForOperation(owner) {
1561
+ const ownerCtx = asNativeActorContext(owner);
1562
+ const active = this.#invocationContext.getStore();
1563
+ if (!(active == null ? void 0 : active.sameActorInstance(ownerCtx))) {
1564
+ return ownerCtx;
1558
1565
  }
1559
- return database;
1566
+ const applicationSpan = readActiveTraceHeaders();
1567
+ if (!applicationSpan) {
1568
+ return active;
1569
+ }
1570
+ return active.withApplicationSpan(
1571
+ applicationSpan.traceparent,
1572
+ applicationSpan.tracestate ?? null
1573
+ );
1574
+ }
1575
+ #actorSql(ctx) {
1576
+ this.#sqlOpened.add(asNativeActorContext(ctx));
1577
+ return this.#actorContextForOperation(ctx).sql();
1560
1578
  }
1561
1579
  createRegistry() {
1580
+ this.#bindings.setTelemetryLogSink(
1581
+ (event2) => {
1582
+ const fields = { otelEvent: event2.name };
1583
+ const message = event2.message || event2.name;
1584
+ if (event2.level === "error") {
1585
+ logger2().error(fields, message);
1586
+ } else {
1587
+ logger2().warn(fields, message);
1588
+ }
1589
+ }
1590
+ );
1562
1591
  return asRegistryHandle(new this.#bindings.CoreRegistry());
1563
1592
  }
1564
1593
  registerActor(registry, name, factory) {
@@ -1573,6 +1602,9 @@ var NapiCoreRuntime = class {
1573
1602
  async shutdownRegistry(registry) {
1574
1603
  await asNativeRegistry(registry).shutdown();
1575
1604
  }
1605
+ async shutdownTelemetry() {
1606
+ await this.#bindings.shutdownTelemetry();
1607
+ }
1576
1608
  async registryActorStopThresholdMs(registry) {
1577
1609
  return await asNativeRegistry(registry).actorStopThresholdMs() ?? void 0;
1578
1610
  }
@@ -1726,6 +1758,57 @@ var NapiCoreRuntime = class {
1726
1758
  actorId(ctx) {
1727
1759
  return asNativeActorContext(ctx).actorId();
1728
1760
  }
1761
+ runWithActorInvocationContext(ctx, run) {
1762
+ return this.#runAs(asNativeActorContext(ctx), run);
1763
+ }
1764
+ #runAs(nativeCtx, run) {
1765
+ var _a;
1766
+ const span = (_a = nativeCtx.invocationTraceContext()) == null ? void 0 : _a.span;
1767
+ return this.#invocationContext.run(
1768
+ nativeCtx,
1769
+ () => runWithActorInvocationSpan(span, run)
1770
+ );
1771
+ }
1772
+ actorInvocationTraceContext(ctx) {
1773
+ return this.#actorContextForOperation(ctx).invocationTraceContext() ?? void 0;
1774
+ }
1775
+ startCallSpan(ctx, actorName, actionName) {
1776
+ const call = this.#actorContextForOperation(ctx).startCallSpan(
1777
+ actorName,
1778
+ actionName
1779
+ );
1780
+ if (!call) return void 0;
1781
+ return {
1782
+ span: call.spanContext() ?? void 0,
1783
+ finish: (error) => call.finish(error)
1784
+ };
1785
+ }
1786
+ async startWorkflowSpan(ctx) {
1787
+ const span = await asNativeActorContext(ctx).startWorkflowSpan();
1788
+ const spanCtx = span.ctx();
1789
+ return {
1790
+ run: (body) => this.#runAs(spanCtx, body),
1791
+ startStep: (name, attempt) => {
1792
+ const step = spanCtx.startWorkflowStepSpan(name, attempt);
1793
+ if (!step) return void 0;
1794
+ const stepCtx = step.ctx();
1795
+ return {
1796
+ run: (body) => this.#runAs(stepCtx, body),
1797
+ finish: (outcome, error) => step.finish(
1798
+ outcome,
1799
+ error === void 0 ? void 0 : encodeErrorForBridge(error)
1800
+ )
1801
+ };
1802
+ },
1803
+ finish: (outcome) => span.finish(outcome)
1804
+ };
1805
+ }
1806
+ runOutsideActorInvocationContext(run) {
1807
+ return this.#invocationContext.exit(run);
1808
+ }
1809
+ currentInvocationScope() {
1810
+ return this.#invocationContext.getStore();
1811
+ }
1729
1812
  actorName(ctx) {
1730
1813
  return asNativeActorContext(ctx).name();
1731
1814
  }
@@ -1757,7 +1840,7 @@ var NapiCoreRuntime = class {
1757
1840
  asNativeActorContext(ctx).broadcast(name, toNapiBuffer(args));
1758
1841
  }
1759
1842
  actorWaitUntil(ctx, promise) {
1760
- asNativeActorContext(ctx).waitUntil(promise);
1843
+ this.#actorContextForOperation(ctx).waitUntil(promise);
1761
1844
  }
1762
1845
  async actorWaitForTrackedShutdownWork(ctx) {
1763
1846
  return await asNativeActorContext(ctx).waitForTrackedShutdownWork();
@@ -1858,7 +1941,7 @@ var NapiCoreRuntime = class {
1858
1941
  await asNativeSqlTransaction(transaction).rollback();
1859
1942
  }
1860
1943
  async actorBeginStateTransaction(ctx, timeoutMs) {
1861
- return await asNativeActorContext(ctx).beginStateTransaction(
1944
+ return await this.#actorContextForOperation(ctx).beginStateTransaction(
1862
1945
  timeoutMs
1863
1946
  );
1864
1947
  }
@@ -1896,23 +1979,21 @@ var NapiCoreRuntime = class {
1896
1979
  }
1897
1980
  async actorSqlClose(ctx) {
1898
1981
  const nativeCtx = asNativeActorContext(ctx);
1899
- const database = this.#sql.get(nativeCtx);
1900
- if (!database) {
1982
+ if (!this.#sqlOpened.delete(nativeCtx)) {
1901
1983
  return;
1902
1984
  }
1903
- this.#sql.delete(nativeCtx);
1904
- await database.close();
1985
+ await nativeCtx.sql().close();
1905
1986
  }
1906
1987
  async actorRuntimeSocketProvision(ctx) {
1907
1988
  return await asNativeActorContext(ctx).provisionActorRuntimeSocket();
1908
1989
  }
1909
1990
  async actorQueueSend(ctx, name, body) {
1910
1991
  return toNapiQueueMessage(
1911
- await asNativeActorContext(ctx).queue().send(name, toNapiBuffer(body))
1992
+ await this.#actorContextForOperation(ctx).queue().send(name, toNapiBuffer(body))
1912
1993
  );
1913
1994
  }
1914
1995
  async actorQueueNextBatch(ctx, options, signal) {
1915
- const messages = await asNativeActorContext(ctx).queue().nextBatch(
1996
+ const messages = await this.#actorContextForOperation(ctx).queue().nextBatch(
1916
1997
  options,
1917
1998
  signal ? asNativeCancellationToken(signal) : signal
1918
1999
  );
@@ -1920,7 +2001,7 @@ var NapiCoreRuntime = class {
1920
2001
  }
1921
2002
  async actorQueueWaitForNames(ctx, names, options, signal) {
1922
2003
  return toNapiQueueMessage(
1923
- await asNativeActorContext(ctx).queue().waitForNames(
2004
+ await this.#actorContextForOperation(ctx).queue().waitForNames(
1924
2005
  names,
1925
2006
  options,
1926
2007
  signal ? asNativeCancellationToken(signal) : signal
@@ -1942,7 +2023,7 @@ var NapiCoreRuntime = class {
1942
2023
  );
1943
2024
  }
1944
2025
  async actorQueueEnqueueAndWait(ctx, name, body, options, signal) {
1945
- return await asNativeActorContext(ctx).queue().enqueueAndWait(
2026
+ return await this.#actorContextForOperation(ctx).queue().enqueueAndWait(
1946
2027
  name,
1947
2028
  toNapiBuffer(body),
1948
2029
  options,
@@ -1962,22 +2043,22 @@ var NapiCoreRuntime = class {
1962
2043
  await asNativeActorContext(ctx).queue().reset();
1963
2044
  }
1964
2045
  async actorScheduleAfter(ctx, durationMs, actionName, args) {
1965
- return await asNativeActorContext(ctx).schedule().after(durationMs, actionName, toNapiBuffer(args));
2046
+ return await this.#actorContextForOperation(ctx).schedule().after(durationMs, actionName, toNapiBuffer(args));
1966
2047
  }
1967
2048
  async actorScheduleAt(ctx, timestampMs, actionName, args) {
1968
- return await asNativeActorContext(ctx).schedule().at(timestampMs, actionName, toNapiBuffer(args));
2049
+ return await this.#actorContextForOperation(ctx).schedule().at(timestampMs, actionName, toNapiBuffer(args));
1969
2050
  }
1970
2051
  async actorScheduleCancel(ctx, id) {
1971
- return await asNativeActorContext(ctx).schedule().cancel(id);
2052
+ return await this.#actorContextForOperation(ctx).schedule().cancel(id);
1972
2053
  }
1973
2054
  async actorScheduleGet(ctx, id) {
1974
- return await asNativeActorContext(ctx).schedule().get(id) ?? void 0;
2055
+ return await this.#actorContextForOperation(ctx).schedule().get(id) ?? void 0;
1975
2056
  }
1976
2057
  async actorScheduleList(ctx) {
1977
- return await asNativeActorContext(ctx).schedule().list();
2058
+ return await this.#actorContextForOperation(ctx).schedule().list();
1978
2059
  }
1979
2060
  async actorCronSet(ctx, name, expression, timezone, actionName, args, maxHistory) {
1980
- await asNativeActorContext(ctx).schedule().cronSet(
2061
+ await this.#actorContextForOperation(ctx).schedule().cronSet(
1981
2062
  name,
1982
2063
  expression,
1983
2064
  timezone,
@@ -1987,7 +2068,7 @@ var NapiCoreRuntime = class {
1987
2068
  );
1988
2069
  }
1989
2070
  async actorCronEvery(ctx, name, intervalMs, actionName, args, maxHistory) {
1990
- await asNativeActorContext(ctx).schedule().cronEvery(
2071
+ await this.#actorContextForOperation(ctx).schedule().cronEvery(
1991
2072
  name,
1992
2073
  intervalMs,
1993
2074
  actionName,
@@ -1996,16 +2077,16 @@ var NapiCoreRuntime = class {
1996
2077
  );
1997
2078
  }
1998
2079
  async actorCronGet(ctx, name) {
1999
- return await asNativeActorContext(ctx).schedule().cronGet(name) ?? void 0;
2080
+ return await this.#actorContextForOperation(ctx).schedule().cronGet(name) ?? void 0;
2000
2081
  }
2001
2082
  async actorCronList(ctx) {
2002
- return await asNativeActorContext(ctx).schedule().cronList();
2083
+ return await this.#actorContextForOperation(ctx).schedule().cronList();
2003
2084
  }
2004
2085
  async actorCronDelete(ctx, name) {
2005
- return await asNativeActorContext(ctx).schedule().cronDelete(name);
2086
+ return await this.#actorContextForOperation(ctx).schedule().cronDelete(name);
2006
2087
  }
2007
2088
  async actorCronHistory(ctx, name, limit) {
2008
- return await asNativeActorContext(ctx).schedule().cronHistory(name, limit);
2089
+ return await this.#actorContextForOperation(ctx).schedule().cronHistory(name, limit);
2009
2090
  }
2010
2091
  connId(conn) {
2011
2092
  return asNativeConn(conn).id();
@@ -2039,10 +2120,13 @@ var NapiCoreRuntime = class {
2039
2120
  }
2040
2121
  };
2041
2122
  async function loadNapiRuntime() {
2042
- const bindings = await import(["@rivetkit", "rivetkit-napi"].join("/"));
2123
+ const [{ AsyncLocalStorage }, bindings] = await Promise.all([
2124
+ import("async_hooks"),
2125
+ import(["@rivetkit", "rivetkit-napi"].join("/"))
2126
+ ]);
2043
2127
  return {
2044
2128
  bindings,
2045
- runtime: new NapiCoreRuntime(bindings)
2129
+ runtime: new NapiCoreRuntime(bindings, new AsyncLocalStorage())
2046
2130
  };
2047
2131
  }
2048
2132
 
@@ -2742,6 +2826,29 @@ var WasmCoreRuntime = class {
2742
2826
  actorId(ctx) {
2743
2827
  return callHandle(asWasmActorContext(ctx), "actorId");
2744
2828
  }
2829
+ runWithActorInvocationContext(_ctx, run) {
2830
+ return run();
2831
+ }
2832
+ actorInvocationTraceContext(_ctx) {
2833
+ return void 0;
2834
+ }
2835
+ startCallSpan(_ctx, _actorName, _actionName) {
2836
+ return void 0;
2837
+ }
2838
+ async startWorkflowSpan(_ctx) {
2839
+ return {
2840
+ run: (body) => body(),
2841
+ startStep: () => void 0,
2842
+ finish: async () => {
2843
+ }
2844
+ };
2845
+ }
2846
+ runOutsideActorInvocationContext(run) {
2847
+ return run();
2848
+ }
2849
+ currentInvocationScope() {
2850
+ return void 0;
2851
+ }
2745
2852
  actorName(ctx) {
2746
2853
  return callHandle(asWasmActorContext(ctx), "name");
2747
2854
  }
@@ -5055,6 +5162,7 @@ var NativeConnectionMap = class {
5055
5162
  }
5056
5163
  [Symbol.toStringTag] = "NativeConnectionMap";
5057
5164
  };
5165
+ var NO_INVOCATION_SCOPE = {};
5058
5166
  var ActorContextHandleAdapter = class {
5059
5167
  #runtime;
5060
5168
  #ctx;
@@ -5069,6 +5177,7 @@ var ActorContextHandleAdapter = class {
5069
5177
  #db;
5070
5178
  #dispatchCancelToken;
5071
5179
  #kv;
5180
+ #logByInvocationScope = /* @__PURE__ */ new WeakMap();
5072
5181
  #queue;
5073
5182
  #request;
5074
5183
  #schedule;
@@ -5211,7 +5320,11 @@ var ActorContextHandleAdapter = class {
5211
5320
  await callNative(
5212
5321
  () => this.#runtime.actorSetRunWakeAt(this.#ctx, timestamp)
5213
5322
  );
5214
- }
5323
+ },
5324
+ startWorkflowSpan: () => callNative(
5325
+ () => this.#runtime.startWorkflowSpan(this.#ctx)
5326
+ ),
5327
+ runOutsideWorkflowSpan: (body) => this.#runtime.runOutsideActorInvocationContext(body)
5215
5328
  };
5216
5329
  }
5217
5330
  return this.#run;
@@ -5256,8 +5369,29 @@ var ActorContextHandleAdapter = class {
5256
5369
  }
5257
5370
  return this.#connMap;
5258
5371
  }
5372
+ #invocationTraceContext() {
5373
+ return callNativeSync(
5374
+ () => this.#runtime.actorInvocationTraceContext(this.#ctx)
5375
+ );
5376
+ }
5377
+ /** Cached per invocation, because the `run` context outlives workflow runs and steps. */
5259
5378
  get log() {
5260
- return logger2();
5379
+ const scope = this.#runtime.currentInvocationScope() ?? NO_INVOCATION_SCOPE;
5380
+ const cached = this.#logByInvocationScope.get(scope);
5381
+ if (cached) return cached;
5382
+ const invocation = this.#invocationTraceContext();
5383
+ const log = logger2().child({
5384
+ actorId: this.actorId,
5385
+ actorName: this.name,
5386
+ actorKey: this.key,
5387
+ ...(invocation == null ? void 0 : invocation.rayId) && { rayId: invocation.rayId },
5388
+ ...(invocation == null ? void 0 : invocation.span) && {
5389
+ traceId: invocation.span.traceId,
5390
+ spanId: invocation.span.spanId
5391
+ }
5392
+ });
5393
+ this.#logByInvocationScope.set(scope, log);
5394
+ return log;
5261
5395
  }
5262
5396
  get abortSignal() {
5263
5397
  if (!this.#abortSignal) {
@@ -5923,6 +6057,13 @@ function withConnContext(runtime, ctx, conn, clientFactory, schemas = {}, databa
5923
6057
  )
5924
6058
  });
5925
6059
  }
6060
+ function buildActorTracingConfig(actions, tracing) {
6061
+ if (tracing === void 0) return void 0;
6062
+ return {
6063
+ sampler: tracing.sampler,
6064
+ actions: flattenActionTraceSamplers(actions, tracing.actions)
6065
+ };
6066
+ }
5926
6067
  function buildActorConfig(definition, registryConfig, runtimeKind) {
5927
6068
  var _a;
5928
6069
  const config = definition.config;
@@ -5936,6 +6077,10 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
5936
6077
  hasDatabase: true,
5937
6078
  remoteSqlite: usesRemoteSqlite,
5938
6079
  sqliteProfiling,
6080
+ tracing: buildActorTracingConfig(
6081
+ definition.config.actions,
6082
+ definition.config.tracing
6083
+ ),
5939
6084
  enableActorRuntimeSocket: options.enableActorRuntimeSocket === true,
5940
6085
  hasState: config.state !== void 0 || typeof config.createState === "function",
5941
6086
  canHibernateWebsocket: typeof canHibernate === "boolean" ? canHibernate : void 0,
@@ -6045,11 +6190,19 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6045
6190
  events: config.events,
6046
6191
  queues: config.queues
6047
6192
  };
6048
- const createClient = () => createClientWithDriver(
6193
+ const createClient = (ctx) => createClientWithDriver(
6049
6194
  new RemoteEngineControlClient(
6050
6195
  convertRegistryConfigToClientConfig(registryConfig)
6051
6196
  ),
6052
- { encoding: "bare" }
6197
+ {
6198
+ encoding: "bare",
6199
+ currentActorInvocation: () => callNativeSync(
6200
+ () => runtime.actorInvocationTraceContext(ctx)
6201
+ ),
6202
+ startCallSpan: (actorName, actionName) => callNativeSync(
6203
+ () => runtime.startCallSpan(ctx, actorName, actionName)
6204
+ )
6205
+ }
6053
6206
  );
6054
6207
  const run = getRunFunction(config.run);
6055
6208
  const runHandlerCoordinator = getRunInspectorKind(config.run) === "workflow" ? new RunHandlerCoordinator(config.run) : void 0;
@@ -6072,7 +6225,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6072
6225
  const makeActorCtx = (ctx, request, cancelToken) => new ActorContextHandleAdapter(
6073
6226
  runtime,
6074
6227
  ctx,
6075
- createClient,
6228
+ () => createClient(ctx),
6076
6229
  schemaConfig,
6077
6230
  databaseProvider,
6078
6231
  request,
@@ -6085,7 +6238,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6085
6238
  runtime,
6086
6239
  ctx,
6087
6240
  conn,
6088
- createClient,
6241
+ () => createClient(ctx),
6089
6242
  schemaConfig,
6090
6243
  databaseProvider,
6091
6244
  request,
@@ -6798,111 +6951,125 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6798
6951
  async (error, payload) => {
6799
6952
  try {
6800
6953
  const { ctx, request, cancelToken, responseBodyStream } = unwrapTsfnPayload(error, payload);
6801
- const inspectorResponse = await maybeHandleNativeInspectorRequest(ctx, request);
6802
- if (inspectorResponse) {
6803
- await cancelNativeHttpRequestBody(request.bodyStream);
6804
- return (await convertNativeHttpResponse(
6805
- inspectorResponse,
6806
- responseBodyStream
6807
- )).response;
6808
- }
6809
- if (typeof config.onRequest !== "function") {
6810
- await cancelNativeHttpRequestBody(request.bodyStream);
6811
- return (await convertNativeHttpResponse(
6812
- new Response(null, { status: 404 }),
6813
- responseBodyStream
6814
- )).response;
6815
- }
6816
- const requestAbortController = new AbortController();
6817
- const handlerRequest = buildNativeHttpRequest({
6818
- ...request,
6819
- abortController: requestAbortController
6820
- });
6821
- const rawConnParams = handlerRequest.headers.get(HEADER_CONN_PARAMS);
6822
- let requestCtx;
6823
- let conn;
6824
- let removeRequestAbortListener;
6825
- let cleanupDeferredToBody = false;
6826
- let cleanedUp = false;
6827
- const cleanupRequest = async () => {
6828
- if (cleanedUp) return;
6829
- cleanedUp = true;
6830
- removeRequestAbortListener == null ? void 0 : removeRequestAbortListener();
6831
- try {
6832
- await (requestCtx == null ? void 0 : requestCtx.dispose());
6833
- } finally {
6834
- if (conn) {
6835
- await runtime.connDisconnect(conn);
6836
- }
6837
- }
6838
- };
6839
- try {
6840
- const connParams = validateConnParams(
6841
- schemaConfig.connParamsSchema,
6842
- rawConnParams ? JSON.parse(rawConnParams) : void 0
6843
- );
6844
- conn = await callNative(
6845
- () => runtime.actorConnectConn(
6954
+ return await runtime.runWithActorInvocationContext(
6955
+ ctx,
6956
+ async () => {
6957
+ const inspectorResponse = await maybeHandleNativeInspectorRequest(
6846
6958
  ctx,
6847
- encodeValue(connParams),
6848
6959
  request
6849
- )
6850
- );
6851
- requestCtx = makeConnCtx(
6852
- ctx,
6853
- conn,
6854
- handlerRequest,
6855
- cancelToken
6856
- );
6857
- const ctxAbortSignal = requestCtx.abortSignal;
6858
- const abortRequest = () => requestAbortController.abort(ctxAbortSignal.reason);
6859
- if (ctxAbortSignal.aborted) {
6860
- abortRequest();
6861
- } else {
6862
- ctxAbortSignal.addEventListener(
6863
- "abort",
6864
- abortRequest,
6865
- { once: true }
6866
6960
  );
6867
- removeRequestAbortListener = () => ctxAbortSignal.removeEventListener(
6868
- "abort",
6869
- abortRequest
6870
- );
6871
- }
6872
- const response = await config.onRequest(
6873
- requestCtx,
6874
- handlerRequest
6875
- );
6876
- if (!isResponseLike(response)) {
6877
- throw new Error(
6878
- "onRequest handler must return a Response"
6879
- );
6880
- }
6881
- const conversion = await convertNativeHttpResponse(
6882
- response,
6883
- responseBodyStream
6884
- );
6885
- if (conversion.bodyCompletion) {
6886
- cleanupDeferredToBody = true;
6887
- void conversion.bodyCompletion.then(cleanupRequest).catch((cleanupError) => {
6888
- logger2().error({
6889
- msg: "failed to clean up native streaming http request",
6890
- error: cleanupError
6891
- });
6961
+ if (inspectorResponse) {
6962
+ await cancelNativeHttpRequestBody(
6963
+ request.bodyStream
6964
+ );
6965
+ return (await convertNativeHttpResponse(
6966
+ inspectorResponse,
6967
+ responseBodyStream
6968
+ )).response;
6969
+ }
6970
+ if (typeof config.onRequest !== "function") {
6971
+ await cancelNativeHttpRequestBody(
6972
+ request.bodyStream
6973
+ );
6974
+ return (await convertNativeHttpResponse(
6975
+ new Response(null, { status: 404 }),
6976
+ responseBodyStream
6977
+ )).response;
6978
+ }
6979
+ const requestAbortController = new AbortController();
6980
+ const handlerRequest = buildNativeHttpRequest({
6981
+ ...request,
6982
+ abortController: requestAbortController
6892
6983
  });
6893
- }
6894
- return conversion.response;
6895
- } finally {
6896
- try {
6897
- await cancelNativeHttpRequestBody(
6898
- request.bodyStream
6899
- );
6900
- } finally {
6901
- if (!cleanupDeferredToBody) {
6902
- await cleanupRequest();
6984
+ const rawConnParams = handlerRequest.headers.get(HEADER_CONN_PARAMS);
6985
+ let requestCtx;
6986
+ let conn;
6987
+ let removeRequestAbortListener;
6988
+ let cleanupDeferredToBody = false;
6989
+ let cleanedUp = false;
6990
+ const cleanupRequest = async () => {
6991
+ if (cleanedUp) return;
6992
+ cleanedUp = true;
6993
+ removeRequestAbortListener == null ? void 0 : removeRequestAbortListener();
6994
+ try {
6995
+ await (requestCtx == null ? void 0 : requestCtx.dispose());
6996
+ } finally {
6997
+ if (conn) {
6998
+ await runtime.connDisconnect(conn);
6999
+ }
7000
+ }
7001
+ };
7002
+ try {
7003
+ const connParams = validateConnParams(
7004
+ schemaConfig.connParamsSchema,
7005
+ rawConnParams ? JSON.parse(rawConnParams) : void 0
7006
+ );
7007
+ conn = await callNative(
7008
+ () => runtime.actorConnectConn(
7009
+ ctx,
7010
+ encodeValue(connParams),
7011
+ request
7012
+ )
7013
+ );
7014
+ requestCtx = makeConnCtx(
7015
+ ctx,
7016
+ conn,
7017
+ handlerRequest,
7018
+ cancelToken
7019
+ );
7020
+ const ctxAbortSignal = requestCtx.abortSignal;
7021
+ const abortRequest = () => requestAbortController.abort(
7022
+ ctxAbortSignal.reason
7023
+ );
7024
+ if (ctxAbortSignal.aborted) {
7025
+ abortRequest();
7026
+ } else {
7027
+ ctxAbortSignal.addEventListener(
7028
+ "abort",
7029
+ abortRequest,
7030
+ { once: true }
7031
+ );
7032
+ removeRequestAbortListener = () => ctxAbortSignal.removeEventListener(
7033
+ "abort",
7034
+ abortRequest
7035
+ );
7036
+ }
7037
+ const response = await config.onRequest(
7038
+ requestCtx,
7039
+ handlerRequest
7040
+ );
7041
+ if (!isResponseLike(response)) {
7042
+ throw new Error(
7043
+ "onRequest handler must return a Response"
7044
+ );
7045
+ }
7046
+ const conversion = await convertNativeHttpResponse(
7047
+ response,
7048
+ responseBodyStream
7049
+ );
7050
+ if (conversion.bodyCompletion) {
7051
+ cleanupDeferredToBody = true;
7052
+ void conversion.bodyCompletion.then(cleanupRequest).catch((cleanupError) => {
7053
+ logger2().error({
7054
+ msg: "failed to clean up native streaming http request",
7055
+ error: cleanupError
7056
+ });
7057
+ });
7058
+ }
7059
+ return conversion.response;
7060
+ } finally {
7061
+ try {
7062
+ await cancelNativeHttpRequestBody(
7063
+ request.bodyStream
7064
+ );
7065
+ } finally {
7066
+ if (!cleanupDeferredToBody) {
7067
+ await cleanupRequest();
7068
+ }
7069
+ }
6903
7070
  }
6904
7071
  }
6905
- }
7072
+ );
6906
7073
  } catch (error2) {
6907
7074
  logger2().error({
6908
7075
  msg: "native onRequest failed",
@@ -6990,21 +7157,27 @@ function buildNativeFactory(runtime, registryConfig, definition) {
6990
7157
  async (error, payload) => {
6991
7158
  const { ctx, conn, args, scheduledFire, cancelToken } = unwrapTsfnPayload(error, payload);
6992
7159
  const actorCtx = conn != null ? makeConnCtx(ctx, conn, void 0, cancelToken) : makeActorCtx(ctx, void 0, cancelToken);
6993
- try {
6994
- return encodeValue(
6995
- await handler(
6996
- actorCtx,
6997
- ...validateActionArgs(
6998
- schemaConfig.actionInputSchemas,
6999
- name,
7000
- decodeArgs(args)
7001
- ),
7002
- ...scheduledFire ? [scheduledFire] : []
7003
- )
7004
- );
7005
- } finally {
7006
- await actorCtx.dispose();
7007
- }
7160
+ const runAction = async () => {
7161
+ try {
7162
+ return encodeValue(
7163
+ await handler(
7164
+ actorCtx,
7165
+ ...validateActionArgs(
7166
+ schemaConfig.actionInputSchemas,
7167
+ name,
7168
+ decodeArgs(args)
7169
+ ),
7170
+ ...scheduledFire ? [scheduledFire] : []
7171
+ )
7172
+ );
7173
+ } finally {
7174
+ await actorCtx.dispose();
7175
+ }
7176
+ };
7177
+ return await runtime.runWithActorInvocationContext(
7178
+ ctx,
7179
+ runAction
7180
+ );
7008
7181
  }
7009
7182
  )
7010
7183
  ])
@@ -7026,7 +7199,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
7026
7199
  runtime,
7027
7200
  ctx,
7028
7201
  conn,
7029
- createClient,
7202
+ () => createClient(ctx),
7030
7203
  schemaConfig,
7031
7204
  databaseProvider,
7032
7205
  jsRequest,
@@ -7035,43 +7208,48 @@ function buildNativeFactory(runtime, registryConfig, definition) {
7035
7208
  cancelToken,
7036
7209
  run !== void 0
7037
7210
  );
7038
- try {
7039
- if (!schemaConfig.queues || !hasSchemaConfigKey(schemaConfig.queues, name)) {
7040
- return { status: "completed" };
7041
- }
7042
- const canPublish = getQueueCanPublish(
7043
- schemaConfig.queues,
7044
- name
7045
- );
7046
- if (canPublish && !await canPublish(actorCtx)) {
7047
- throw forbiddenError();
7048
- }
7049
- const decodedBody = decodeValue(body);
7050
- if (wait) {
7211
+ return await runtime.runWithActorInvocationContext(
7212
+ ctx,
7213
+ async () => {
7051
7214
  try {
7052
- const response = await actorCtx.queue.enqueueAndWait(
7053
- name,
7054
- decodedBody,
7055
- {
7056
- timeout: timeoutMs === void 0 || timeoutMs === null ? void 0 : Number(timeoutMs)
7057
- }
7215
+ if (!schemaConfig.queues || !hasSchemaConfigKey(schemaConfig.queues, name)) {
7216
+ return { status: "completed" };
7217
+ }
7218
+ const canPublish = getQueueCanPublish(
7219
+ schemaConfig.queues,
7220
+ name
7058
7221
  );
7059
- return {
7060
- status: "completed",
7061
- response: response === void 0 ? void 0 : encodeValue(response)
7062
- };
7063
- } catch (error2) {
7064
- if (error2.group === "queue" && error2.code === "timed_out") {
7065
- return { status: "timedOut" };
7222
+ if (canPublish && !await canPublish(actorCtx)) {
7223
+ throw forbiddenError();
7224
+ }
7225
+ const decodedBody = decodeValue(body);
7226
+ if (wait) {
7227
+ try {
7228
+ const response = await actorCtx.queue.enqueueAndWait(
7229
+ name,
7230
+ decodedBody,
7231
+ {
7232
+ timeout: timeoutMs === void 0 || timeoutMs === null ? void 0 : Number(timeoutMs)
7233
+ }
7234
+ );
7235
+ return {
7236
+ status: "completed",
7237
+ response: response === void 0 ? void 0 : encodeValue(response)
7238
+ };
7239
+ } catch (error2) {
7240
+ if (error2.group === "queue" && error2.code === "timed_out") {
7241
+ return { status: "timedOut" };
7242
+ }
7243
+ throw error2;
7244
+ }
7066
7245
  }
7067
- throw error2;
7246
+ await actorCtx.queue.send(name, decodedBody);
7247
+ return { status: "completed" };
7248
+ } finally {
7249
+ await actorCtx.dispose();
7068
7250
  }
7069
7251
  }
7070
- await actorCtx.queue.send(name, decodedBody);
7071
- return { status: "completed" };
7072
- } finally {
7073
- await actorCtx.dispose();
7074
- }
7252
+ );
7075
7253
  }
7076
7254
  ),
7077
7255
  serializeState: wrapNativeCallback(
@@ -7721,6 +7899,7 @@ var Registry = class {
7721
7899
  var _a;
7722
7900
  const modeAPromise = this.#runtimeServeConfiguredPromise;
7723
7901
  const modeBPromise = this.#runtimeServerlessPromise;
7902
+ const runtimes = /* @__PURE__ */ new Set();
7724
7903
  const gracePeriodMs = ((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs) ?? await this.#actorStopThresholdMs(modeAPromise ?? modeBPromise) ?? 30 * 60 * 1e3;
7725
7904
  const drain = async () => {
7726
7905
  const registries = [];
@@ -7729,6 +7908,7 @@ var Registry = class {
7729
7908
  (async () => {
7730
7909
  try {
7731
7910
  const { runtime, registry } = await modeAPromise;
7911
+ runtimes.add(runtime);
7732
7912
  await runtime.shutdownRegistry(registry);
7733
7913
  } catch (err) {
7734
7914
  logger2().warn(
@@ -7744,6 +7924,7 @@ var Registry = class {
7744
7924
  (async () => {
7745
7925
  try {
7746
7926
  const { runtime, registry } = await modeBPromise;
7927
+ runtimes.add(runtime);
7747
7928
  await runtime.shutdownRegistry(registry);
7748
7929
  } catch (err) {
7749
7930
  logger2().warn(
@@ -7772,6 +7953,12 @@ var Registry = class {
7772
7953
  }
7773
7954
  )
7774
7955
  ]);
7956
+ await Promise.all(
7957
+ [...runtimes].map((runtime) => {
7958
+ var _a2;
7959
+ return (_a2 = runtime.shutdownTelemetry) == null ? void 0 : _a2.call(runtime);
7960
+ })
7961
+ );
7775
7962
  }
7776
7963
  async #actorStopThresholdMs(configuredRegistryPromise) {
7777
7964
  var _a;