rivetkit 3.1.2-rc.1 → 3.1.2-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 (103) hide show
  1. package/dist/browser/client.d.ts +3 -43
  2. package/dist/browser/client.js +9 -1
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/{chunk-SPLLB6BX.js → chunk-2BXN54R4.js} +2 -2
  7. package/dist/tsup/{chunk-YT77YM32.js → chunk-3ALVCHXR.js} +3 -3
  8. package/dist/tsup/{chunk-R2GD2TDD.cjs → chunk-6ANYUVLS.cjs} +3 -3
  9. package/dist/tsup/{chunk-R2GD2TDD.cjs.map → chunk-6ANYUVLS.cjs.map} +1 -1
  10. package/dist/tsup/{chunk-5RE3IF3C.js → chunk-6S73EWWS.js} +2 -2
  11. package/dist/tsup/{chunk-MM6QYEV7.cjs → chunk-6YDPLY6F.cjs} +155 -147
  12. package/dist/tsup/chunk-6YDPLY6F.cjs.map +1 -0
  13. package/dist/tsup/{chunk-KOB3RR6D.cjs → chunk-C2I4CPLD.cjs} +7 -7
  14. package/dist/tsup/{chunk-KOB3RR6D.cjs.map → chunk-C2I4CPLD.cjs.map} +1 -1
  15. package/dist/tsup/{chunk-YPJ3QEDL.cjs → chunk-JK62DI4K.cjs} +4 -4
  16. package/dist/tsup/{chunk-YPJ3QEDL.cjs.map → chunk-JK62DI4K.cjs.map} +1 -1
  17. package/dist/tsup/{chunk-TYNEZVC2.cjs → chunk-MJCM3IZN.cjs} +3 -3
  18. package/dist/tsup/{chunk-TYNEZVC2.cjs.map → chunk-MJCM3IZN.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-GI3TPFCE.cjs → chunk-MJWDZ4CU.cjs} +2 -2
  20. package/dist/tsup/{chunk-GI3TPFCE.cjs.map → chunk-MJWDZ4CU.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-TR5YB355.cjs → chunk-P57K5DTD.cjs} +5 -4
  22. package/dist/tsup/chunk-P57K5DTD.cjs.map +1 -0
  23. package/dist/tsup/{chunk-WD6L6OTX.js → chunk-POKN6RC5.js} +2 -2
  24. package/dist/tsup/{chunk-WD6L6OTX.js.map → chunk-POKN6RC5.js.map} +1 -1
  25. package/dist/tsup/{chunk-7PUO5YRK.js → chunk-WCVT6UXF.js} +14 -6
  26. package/dist/tsup/chunk-WCVT6UXF.js.map +1 -0
  27. package/dist/tsup/{chunk-DKVKYLXH.js → chunk-WJSHEWTP.js} +4 -4
  28. package/dist/tsup/{chunk-VUFOIAKH.cjs → chunk-X4HPTBGP.cjs} +10 -10
  29. package/dist/tsup/{chunk-VUFOIAKH.cjs.map → chunk-X4HPTBGP.cjs.map} +1 -1
  30. package/dist/tsup/{chunk-LNMODE5R.js → chunk-YXBMGSYD.js} +4 -3
  31. package/dist/tsup/chunk-YXBMGSYD.js.map +1 -0
  32. package/dist/tsup/{chunk-J5ZNIJT3.js → chunk-ZWLSBELO.js} +2 -2
  33. package/dist/tsup/client/mod.cjs +5 -5
  34. package/dist/tsup/client/mod.d.cts +3 -3
  35. package/dist/tsup/client/mod.d.ts +3 -3
  36. package/dist/tsup/client/mod.js +4 -4
  37. package/dist/tsup/common/log.cjs +2 -2
  38. package/dist/tsup/common/log.js +1 -1
  39. package/dist/tsup/common/websocket.cjs +3 -3
  40. package/dist/tsup/common/websocket.js +2 -2
  41. package/dist/tsup/{config-CTGjM4A5.d.cts → config-BbRMYCV8.d.cts} +4 -18
  42. package/dist/tsup/{config-Df5jOcde.d.ts → config-CBTr4IhE.d.cts} +0 -26
  43. package/dist/tsup/{config-Df5jOcde.d.cts → config-CBTr4IhE.d.ts} +0 -26
  44. package/dist/tsup/{config-DLXQ_TVP.d.ts → config-CW3AWqHa.d.ts} +4 -18
  45. package/dist/tsup/{context-Dmz9Hd6K.d.ts → context-Cp64yaMW.d.ts} +2 -2
  46. package/dist/tsup/{context-S-Y75hj1.d.cts → context-NuwP8HjQ.d.cts} +2 -2
  47. package/dist/tsup/db/drizzle.cjs +2 -2
  48. package/dist/tsup/db/drizzle.d.cts +1 -1
  49. package/dist/tsup/db/drizzle.d.ts +1 -1
  50. package/dist/tsup/db/drizzle.js +1 -1
  51. package/dist/tsup/db/mod.cjs +3 -3
  52. package/dist/tsup/db/mod.d.cts +2 -2
  53. package/dist/tsup/db/mod.d.ts +2 -2
  54. package/dist/tsup/db/mod.js +2 -2
  55. package/dist/tsup/dynamic/mod.d.cts +2 -2
  56. package/dist/tsup/dynamic/mod.d.ts +2 -2
  57. package/dist/tsup/inspector/mod.cjs +5 -5
  58. package/dist/tsup/inspector/mod.js +4 -4
  59. package/dist/tsup/inspector/workflow.cjs +4 -4
  60. package/dist/tsup/inspector/workflow.js +3 -3
  61. package/dist/tsup/inspector-tab/mod.d.cts +3 -3
  62. package/dist/tsup/inspector-tab/mod.d.ts +3 -3
  63. package/dist/tsup/mod.cjs +151 -401
  64. package/dist/tsup/mod.cjs.map +1 -1
  65. package/dist/tsup/mod.d.cts +4 -4
  66. package/dist/tsup/mod.d.ts +4 -4
  67. package/dist/tsup/mod.js +70 -320
  68. package/dist/tsup/mod.js.map +1 -1
  69. package/dist/tsup/test/mod.cjs +6 -6
  70. package/dist/tsup/test/mod.d.cts +2 -2
  71. package/dist/tsup/test/mod.d.ts +2 -2
  72. package/dist/tsup/test/mod.js +4 -4
  73. package/dist/tsup/unstable/migrations.d.cts +1 -1
  74. package/dist/tsup/unstable/migrations.d.ts +1 -1
  75. package/dist/tsup/utils.cjs +2 -2
  76. package/dist/tsup/utils.js +1 -1
  77. package/dist/tsup/workflow/mod.cjs +35 -27
  78. package/dist/tsup/workflow/mod.cjs.map +1 -1
  79. package/dist/tsup/workflow/mod.d.cts +4 -4
  80. package/dist/tsup/workflow/mod.d.ts +4 -4
  81. package/dist/tsup/workflow/mod.js +32 -24
  82. package/dist/tsup/workflow/mod.js.map +1 -1
  83. package/package.json +9 -9
  84. package/src/client/lifecycle-errors.ts +15 -0
  85. package/src/common/database/config.ts +0 -39
  86. package/src/common/database/mod.ts +3 -0
  87. package/src/common/database/native-database.ts +32 -231
  88. package/src/registry/config/index.ts +3 -1
  89. package/src/registry/index.ts +15 -14
  90. package/src/registry/napi-runtime.ts +4 -81
  91. package/src/registry/native.ts +21 -60
  92. package/src/registry/runtime.ts +3 -53
  93. package/src/registry/wasm-runtime.ts +3 -89
  94. package/src/workflow/driver.ts +29 -20
  95. package/dist/tsup/chunk-7PUO5YRK.js.map +0 -1
  96. package/dist/tsup/chunk-LNMODE5R.js.map +0 -1
  97. package/dist/tsup/chunk-MM6QYEV7.cjs.map +0 -1
  98. package/dist/tsup/chunk-TR5YB355.cjs.map +0 -1
  99. /package/dist/tsup/{chunk-SPLLB6BX.js.map → chunk-2BXN54R4.js.map} +0 -0
  100. /package/dist/tsup/{chunk-YT77YM32.js.map → chunk-3ALVCHXR.js.map} +0 -0
  101. /package/dist/tsup/{chunk-5RE3IF3C.js.map → chunk-6S73EWWS.js.map} +0 -0
  102. /package/dist/tsup/{chunk-DKVKYLXH.js.map → chunk-WJSHEWTP.js.map} +0 -0
  103. /package/dist/tsup/{chunk-J5ZNIJT3.js.map → chunk-ZWLSBELO.js.map} +0 -0
@@ -62,11 +62,7 @@ import {
62
62
  db as defaultDb,
63
63
  registerNativeStateTransactionOpener,
64
64
  } from "@/common/database/mod";
65
- import {
66
- type JsNativeDatabaseLike,
67
- type JsNativeSynchronousTransactionLike,
68
- wrapJsNativeDatabase,
69
- } from "@/common/database/native-database";
65
+ import { wrapJsNativeDatabase } from "@/common/database/native-database";
70
66
  import { assertJsonCompatValue, type JsonCompatValue } from "@/common/encoding";
71
67
  import { isResponseLike } from "@/common/fetch-like";
72
68
  import {
@@ -131,7 +127,6 @@ import type {
131
127
  RuntimeScheduledFireInfo,
132
128
  RuntimeServeConfig,
133
129
  RuntimeStateDeltaPayload,
134
- SqliteTransactionHandle,
135
130
  WebSocketHandle,
136
131
  } from "./runtime";
137
132
  import { servicesBinaryUnavailable } from "./runtime";
@@ -662,26 +657,6 @@ async function closeNativeDatabaseClient(
662
657
  }
663
658
  }
664
659
 
665
- function createNativeSqlTransaction(
666
- runtime: CoreRuntime,
667
- transaction: SqliteTransactionHandle,
668
- ): JsNativeSynchronousTransactionLike {
669
- return {
670
- exec: (sql) => runtime.actorSqlTransactionExec(transaction, sql),
671
- execSync: (sql) =>
672
- runtime.actorSqlTransactionExecSync(transaction, sql),
673
- execute: (sql, params) =>
674
- runtime.actorSqlTransactionExecute(transaction, sql, params),
675
- executeSync: (sql, params) =>
676
- runtime.actorSqlTransactionExecuteSync(transaction, sql, params),
677
- commit: () => runtime.actorSqlTransactionCommit(transaction),
678
- commitSync: () => runtime.actorSqlTransactionCommitSync(transaction),
679
- rollback: () => runtime.actorSqlTransactionRollback(transaction),
680
- rollbackSync: () =>
681
- runtime.actorSqlTransactionRollbackSync(transaction),
682
- };
683
- }
684
-
685
660
  function getOrCreateNativeSqlDatabase(
686
661
  runtime: CoreRuntime,
687
662
  ctx: ActorContextHandle,
@@ -692,12 +667,9 @@ function getOrCreateNativeSqlDatabase(
692
667
  return cachedDatabase;
693
668
  }
694
669
 
695
- const bindings: JsNativeDatabaseLike = {
670
+ const database = wrapJsNativeDatabase({
696
671
  exec: (sql) => runtime.actorSqlExec(ctx, sql),
697
- execSync: (sql) => runtime.actorSqlExecSync(ctx, sql),
698
672
  execute: (sql, params) => runtime.actorSqlExecute(ctx, sql, params),
699
- executeSync: (sql, params) =>
700
- runtime.actorSqlExecuteSync(ctx, sql, params),
701
673
  executeBatch: (statements) =>
702
674
  runtime.actorSqlExecuteBatch(ctx, statements),
703
675
  beginTransaction: async (timeoutMs, name) => {
@@ -706,17 +678,21 @@ function getOrCreateNativeSqlDatabase(
706
678
  timeoutMs,
707
679
  name,
708
680
  );
709
- return createNativeSqlTransaction(runtime, transaction);
710
- },
711
- beginTransactionSync: (timeoutMs, name) => {
712
- const transaction = runtime.actorSqlBeginTransactionSync(
713
- ctx,
714
- timeoutMs,
715
- name,
716
- );
717
- return createNativeSqlTransaction(runtime, transaction);
681
+ return {
682
+ exec: (sql) =>
683
+ runtime.actorSqlTransactionExec(transaction, sql),
684
+ execute: (sql, params) =>
685
+ runtime.actorSqlTransactionExecute(
686
+ transaction,
687
+ sql,
688
+ params,
689
+ ),
690
+ commit: () => runtime.actorSqlTransactionCommit(transaction),
691
+ rollback: () =>
692
+ runtime.actorSqlTransactionRollback(transaction),
693
+ };
718
694
  },
719
- beginStateTransaction: async (timeoutMs, context) => {
695
+ beginStateTransaction: async (timeoutMs, context, name) => {
720
696
  const scope = context as NativeStateTransactionScope | undefined;
721
697
  if (!scope) {
722
698
  throw new Error(
@@ -726,6 +702,7 @@ function getOrCreateNativeSqlDatabase(
726
702
  const transaction = await runtime.actorBeginStateTransaction(
727
703
  ctx,
728
704
  timeoutMs,
705
+ name,
729
706
  );
730
707
  return {
731
708
  exec: async () => {
@@ -754,14 +731,8 @@ function getOrCreateNativeSqlDatabase(
754
731
  run: (sql, params) => runtime.actorSqlRun(ctx, sql, params),
755
732
  metrics: () => runtime.actorSqlMetrics(ctx),
756
733
  takeLastKvError: () => runtime.actorSqlTakeLastKvError(ctx),
757
- open: () => runtime.actorSqlOpen(ctx),
758
- commitTicket: () => runtime.actorSqlCommitTicket(ctx),
759
- whenDurable: (ticket) => runtime.actorSqlWhenDurable(ctx, ticket),
760
- abortGeneration: (reason) =>
761
- runtime.actorSqlAbortGeneration(ctx, reason),
762
734
  close: () => runtime.actorSqlClose(ctx),
763
- };
764
- const database = wrapJsNativeDatabase(bindings);
735
+ });
765
736
  runtimeState.sql = database;
766
737
  return database;
767
738
  }
@@ -3225,19 +3196,17 @@ export class ActorContextHandleAdapter {
3225
3196
  {
3226
3197
  open: async (requestedActorId) => {
3227
3198
  void requestedActorId;
3228
- const database = getOrCreateNativeSqlDatabase(
3199
+ return getOrCreateNativeSqlDatabase(
3229
3200
  this.#runtime,
3230
3201
  this.#ctx,
3231
3202
  );
3232
- await database.open();
3233
- return database;
3234
3203
  },
3235
3204
  },
3236
- async (timeoutMs, context) =>
3205
+ async (timeoutMs, context, name) =>
3237
3206
  await getOrCreateNativeSqlDatabase(
3238
3207
  this.#runtime,
3239
3208
  this.#ctx,
3240
- ).beginStateTransaction(timeoutMs, context),
3209
+ ).beginStateTransaction(timeoutMs, context, name),
3241
3210
  ),
3242
3211
  });
3243
3212
  runtimeState.databaseClient = {
@@ -4027,8 +3996,6 @@ function buildActorTracingConfig(
4027
3996
  };
4028
3997
  }
4029
3998
 
4030
- const SQLITE_DEFERRED_COMMITS = Symbol.for("rivetkit.sqlite.deferredCommits");
4031
-
4032
3999
  function buildActorConfig(
4033
4000
  definition: AnyActorDefinition,
4034
4001
  registryConfig: RegistryConfig,
@@ -4042,18 +4009,12 @@ function buildActorConfig(
4042
4009
  const sqliteProfiling = (
4043
4010
  config.db as { sqliteProfiling?: SqliteProfilingOptions } | undefined
4044
4011
  )?.sqliteProfiling;
4045
- // Internal opt-in for embedders that gate every output on `whenDurable`.
4046
- const sqliteDeferredCommits =
4047
- (config.db as Record<symbol, unknown> | undefined)?.[
4048
- SQLITE_DEFERRED_COMMITS
4049
- ] === true;
4050
4012
 
4051
4013
  return {
4052
4014
  name: options.name as string | undefined,
4053
4015
  icon: options.icon as string | undefined,
4054
4016
  hasDatabase: true,
4055
4017
  remoteSqlite: usesRemoteSqlite,
4056
- sqliteDeferredCommits: sqliteDeferredCommits || undefined,
4057
4018
  sqliteProfiling,
4058
4019
  tracing: buildActorTracingConfig(
4059
4020
  definition.config.actions,
@@ -287,15 +287,10 @@ export interface RuntimeSqlRunResult {
287
287
 
288
288
  export interface RuntimeSqlDatabase {
289
289
  exec(sql: string): Promise<RuntimeSqlExecResult>;
290
- execSync(sql: string): RuntimeSqlExecResult;
291
290
  execute(
292
291
  sql: string,
293
292
  params?: RuntimeSqlBindParams,
294
293
  ): Promise<RuntimeSqlExecuteResult>;
295
- executeSync(
296
- sql: string,
297
- params?: RuntimeSqlBindParams,
298
- ): RuntimeSqlExecuteResult;
299
294
  executeBatch(
300
295
  statements: RuntimeSqlBatchStatement[],
301
296
  ): Promise<RuntimeSqlExecuteResult[]>;
@@ -311,33 +306,19 @@ export interface RuntimeSqlDatabase {
311
306
  timeoutMs?: number,
312
307
  name?: string,
313
308
  ): Promise<RuntimeSqlTransactionDatabase>;
314
- beginTransactionSync(
315
- timeoutMs?: number,
316
- name?: string,
317
- ): RuntimeSqlTransactionDatabase;
318
309
  metrics?(): SqliteNativeMetrics | null;
319
310
  takeLastKvError?(): string | null;
320
- open(): Promise<void>;
321
- commitTicket(): number;
322
- whenDurable(ticket: number): Promise<void>;
323
311
  close(): Promise<void>;
324
312
  }
325
313
 
326
314
  export interface RuntimeSqlTransactionDatabase {
327
315
  exec(sql: string): Promise<RuntimeSqlExecResult>;
328
- execSync(sql: string): RuntimeSqlExecResult;
329
316
  execute(
330
317
  sql: string,
331
318
  params?: RuntimeSqlBindParams,
332
319
  ): Promise<RuntimeSqlExecuteResult>;
333
- executeSync(
334
- sql: string,
335
- params?: RuntimeSqlBindParams,
336
- ): RuntimeSqlExecuteResult;
337
320
  commit(): Promise<void>;
338
- commitSync(): void;
339
321
  rollback(): Promise<void>;
340
- rollbackSync(): void;
341
322
  }
342
323
 
343
324
  /** Sample rates for the traces an actor starts, in the shape core takes. */
@@ -352,7 +333,6 @@ export interface RuntimeActorConfig {
352
333
  icon?: string;
353
334
  hasDatabase?: boolean;
354
335
  remoteSqlite?: boolean;
355
- sqliteDeferredCommits?: boolean;
356
336
  sqliteProfiling?: SqliteProfilingOptions;
357
337
  tracing?: RuntimeActorTracingConfig;
358
338
  hasState?: boolean;
@@ -519,7 +499,8 @@ export interface CoreRuntime {
519
499
  waitRegistryReady(registry: RegistryHandle): Promise<void>;
520
500
  shutdownRegistry(registry: RegistryHandle): Promise<void>;
521
501
  shutdownTelemetry?(): Promise<void>;
522
- registryActorStopThresholdMs?(
502
+ /** The engine's drain period plus its actor stop threshold, once the node connected. */
503
+ registryShutdownBudgetMs?(
523
504
  registry: RegistryHandle,
524
505
  ): Promise<number | undefined>;
525
506
  registryActiveActorCount?(registry: RegistryHandle): number;
@@ -728,20 +709,11 @@ export interface CoreRuntime {
728
709
  ctx: ActorContextHandle,
729
710
  sql: string,
730
711
  ): Promise<RuntimeSqlExecResult>;
731
- actorSqlExecSync(
732
- ctx: ActorContextHandle,
733
- sql: string,
734
- ): RuntimeSqlExecResult;
735
712
  actorSqlExecute(
736
713
  ctx: ActorContextHandle,
737
714
  sql: string,
738
715
  params?: RuntimeSqlBindParams,
739
716
  ): Promise<RuntimeSqlExecuteResult>;
740
- actorSqlExecuteSync(
741
- ctx: ActorContextHandle,
742
- sql: string,
743
- params?: RuntimeSqlBindParams,
744
- ): RuntimeSqlExecuteResult;
745
717
  actorSqlExecuteBatch(
746
718
  ctx: ActorContextHandle,
747
719
  statements: RuntimeSqlBatchStatement[],
@@ -751,40 +723,25 @@ export interface CoreRuntime {
751
723
  timeoutMs?: number,
752
724
  name?: string,
753
725
  ): Promise<SqliteTransactionHandle>;
754
- actorSqlBeginTransactionSync(
755
- ctx: ActorContextHandle,
756
- timeoutMs?: number,
757
- name?: string,
758
- ): SqliteTransactionHandle;
759
726
  actorSqlTransactionExec(
760
727
  transaction: SqliteTransactionHandle,
761
728
  sql: string,
762
729
  ): Promise<RuntimeSqlExecResult>;
763
- actorSqlTransactionExecSync(
764
- transaction: SqliteTransactionHandle,
765
- sql: string,
766
- ): RuntimeSqlExecResult;
767
730
  actorSqlTransactionExecute(
768
731
  transaction: SqliteTransactionHandle,
769
732
  sql: string,
770
733
  params?: RuntimeSqlBindParams,
771
734
  ): Promise<RuntimeSqlExecuteResult>;
772
- actorSqlTransactionExecuteSync(
773
- transaction: SqliteTransactionHandle,
774
- sql: string,
775
- params?: RuntimeSqlBindParams,
776
- ): RuntimeSqlExecuteResult;
777
735
  actorSqlTransactionCommit(
778
736
  transaction: SqliteTransactionHandle,
779
737
  ): Promise<void>;
780
- actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void;
781
738
  actorSqlTransactionRollback(
782
739
  transaction: SqliteTransactionHandle,
783
740
  ): Promise<void>;
784
- actorSqlTransactionRollbackSync(transaction: SqliteTransactionHandle): void;
785
741
  actorBeginStateTransaction(
786
742
  ctx: ActorContextHandle,
787
743
  timeoutMs?: number,
744
+ name?: string,
788
745
  ): Promise<ActorStateTransactionHandle>;
789
746
  actorStateTransactionExecute(
790
747
  transaction: ActorStateTransactionHandle,
@@ -810,13 +767,6 @@ export interface CoreRuntime {
810
767
  ): Promise<RuntimeSqlRunResult>;
811
768
  actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
812
769
  actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
813
- /** Opens the actor database so later synchronous calls never fetch its first pages. */
814
- actorSqlOpen(ctx: ActorContextHandle): Promise<void>;
815
- /** Returns the ticket of the latest local commit. */
816
- actorSqlCommitTicket(ctx: ActorContextHandle): number;
817
- /** Resolves once the commit `ticket` names and every earlier commit are durable. */
818
- actorSqlWhenDurable(ctx: ActorContextHandle, ticket: number): Promise<void>;
819
- actorSqlAbortGeneration(ctx: ActorContextHandle, reason: string): void;
820
770
  actorSqlClose(ctx: ActorContextHandle): Promise<void>;
821
771
 
822
772
  actorQueueSend(
@@ -151,18 +151,6 @@ function wasmNumber(value: number | bigint): number {
151
151
  return typeof value === "bigint" ? Number(value) : value;
152
152
  }
153
153
 
154
- function synchronousSqliteUnavailable(): never {
155
- throw new RivetError(
156
- "sqlite",
157
- "sync_unsupported",
158
- "Synchronous SQLite is unavailable because the actor runs on the wasm runtime.",
159
- {
160
- public: true,
161
- metadata: { runtime: "wasm" },
162
- },
163
- );
164
- }
165
-
166
154
  function normalizeKvEntry(entry: RuntimeKvEntry): RuntimeKvEntry {
167
155
  return {
168
156
  key: toBytes(entry.key),
@@ -380,14 +368,6 @@ export class WasmCoreRuntime implements CoreRuntime {
380
368
  callbacks: object,
381
369
  config?: RuntimeActorConfig | undefined | null,
382
370
  ): ActorFactoryHandle {
383
- if (config?.sqliteDeferredCommits) {
384
- throw new RivetError(
385
- "sqlite",
386
- "deferred_commits_unsupported",
387
- "SQLite deferred commits require local native SQLite, but the wasm runtime uses remote SQLite.",
388
- { metadata: { runtime: "wasm" } },
389
- );
390
- }
391
371
  return callWasmSync(() =>
392
372
  asActorFactoryHandle(
393
373
  new this.#constructors.ActorFactory(callbacks, config),
@@ -829,13 +809,6 @@ export class WasmCoreRuntime implements CoreRuntime {
829
809
  return await callWasm(() => this.#actorSql(ctx).exec(sql));
830
810
  }
831
811
 
832
- actorSqlExecSync(
833
- _ctx: ActorContextHandle,
834
- _sql: string,
835
- ): RuntimeSqlExecResult {
836
- return synchronousSqliteUnavailable();
837
- }
838
-
839
812
  async actorSqlExecute(
840
813
  ctx: ActorContextHandle,
841
814
  sql: string,
@@ -847,14 +820,6 @@ export class WasmCoreRuntime implements CoreRuntime {
847
820
  return normalizeRuntimeSqlExecuteResult(result);
848
821
  }
849
822
 
850
- actorSqlExecuteSync(
851
- _ctx: ActorContextHandle,
852
- _sql: string,
853
- _params?: RuntimeSqlBindParams,
854
- ): RuntimeSqlExecuteResult {
855
- return synchronousSqliteUnavailable();
856
- }
857
-
858
823
  async actorSqlExecuteBatch(
859
824
  ctx: ActorContextHandle,
860
825
  statements: RuntimeSqlBatchStatement[],
@@ -875,14 +840,6 @@ export class WasmCoreRuntime implements CoreRuntime {
875
840
  )) as unknown as SqliteTransactionHandle;
876
841
  }
877
842
 
878
- actorSqlBeginTransactionSync(
879
- _ctx: ActorContextHandle,
880
- _timeoutMs?: number,
881
- _name?: string,
882
- ): SqliteTransactionHandle {
883
- return synchronousSqliteUnavailable();
884
- }
885
-
886
843
  async actorSqlTransactionExec(
887
844
  transaction: SqliteTransactionHandle,
888
845
  sql: string,
@@ -896,13 +853,6 @@ export class WasmCoreRuntime implements CoreRuntime {
896
853
  );
897
854
  }
898
855
 
899
- actorSqlTransactionExecSync(
900
- _transaction: SqliteTransactionHandle,
901
- _sql: string,
902
- ): RuntimeSqlExecResult {
903
- return synchronousSqliteUnavailable();
904
- }
905
-
906
856
  async actorSqlTransactionExecute(
907
857
  transaction: SqliteTransactionHandle,
908
858
  sql: string,
@@ -921,14 +871,6 @@ export class WasmCoreRuntime implements CoreRuntime {
921
871
  return normalizeRuntimeSqlExecuteResult(result);
922
872
  }
923
873
 
924
- actorSqlTransactionExecuteSync(
925
- _transaction: SqliteTransactionHandle,
926
- _sql: string,
927
- _params?: RuntimeSqlBindParams,
928
- ): RuntimeSqlExecuteResult {
929
- return synchronousSqliteUnavailable();
930
- }
931
-
932
874
  async actorSqlTransactionCommit(
933
875
  transaction: SqliteTransactionHandle,
934
876
  ): Promise<void> {
@@ -937,10 +879,6 @@ export class WasmCoreRuntime implements CoreRuntime {
937
879
  );
938
880
  }
939
881
 
940
- actorSqlTransactionCommitSync(_transaction: SqliteTransactionHandle): void {
941
- synchronousSqliteUnavailable();
942
- }
943
-
944
882
  async actorSqlTransactionRollback(
945
883
  transaction: SqliteTransactionHandle,
946
884
  ): Promise<void> {
@@ -950,25 +888,20 @@ export class WasmCoreRuntime implements CoreRuntime {
950
888
  ).rollback(),
951
889
  );
952
890
  }
953
-
954
- actorSqlTransactionRollbackSync(
955
- _transaction: SqliteTransactionHandle,
956
- ): void {
957
- synchronousSqliteUnavailable();
958
- }
959
-
960
891
  async actorBeginStateTransaction(
961
892
  ctx: ActorContextHandle,
962
893
  timeoutMs?: number,
894
+ name?: string,
963
895
  ): Promise<ActorStateTransactionHandle> {
964
896
  return (await callWasm(() =>
965
897
  (
966
898
  asWasmActorContext(ctx) as unknown as {
967
899
  beginStateTransaction(
968
900
  timeoutMs?: number,
901
+ name?: string,
969
902
  ): Promise<ActorStateTransactionHandle>;
970
903
  }
971
- ).beginStateTransaction(timeoutMs),
904
+ ).beginStateTransaction(timeoutMs, name),
972
905
  )) as ActorStateTransactionHandle;
973
906
  }
974
907
 
@@ -1037,25 +970,6 @@ export class WasmCoreRuntime implements CoreRuntime {
1037
970
  return this.#actorSql(ctx).takeLastKvError?.() ?? null;
1038
971
  }
1039
972
 
1040
- async actorSqlOpen(_ctx: ActorContextHandle): Promise<void> {
1041
- // Remote SQLite opens on the engine side with each request.
1042
- }
1043
-
1044
- actorSqlCommitTicket(_ctx: ActorContextHandle): number {
1045
- return synchronousSqliteUnavailable();
1046
- }
1047
-
1048
- actorSqlAbortGeneration(_ctx: ActorContextHandle, _reason: string): void {
1049
- synchronousSqliteUnavailable();
1050
- }
1051
-
1052
- async actorSqlWhenDurable(
1053
- _ctx: ActorContextHandle,
1054
- _ticket: number,
1055
- ): Promise<void> {
1056
- synchronousSqliteUnavailable();
1057
- }
1058
-
1059
973
  async actorSqlClose(ctx: ActorContextHandle): Promise<void> {
1060
974
  const wasmCtx = asWasmActorContext(ctx);
1061
975
  const database = this.#sql.get(wasmCtx);
@@ -17,6 +17,9 @@ const WORKFLOW_STORAGE_PREFIX = workflowStoragePrefix();
17
17
  // and index pages, so it needs the same conservative budget as core imports.
18
18
  const WORKFLOW_SQLITE_MAX_BATCH_ROWS = 128;
19
19
  const WORKFLOW_SQLITE_MAX_BATCH_BYTES = 512 * 1024;
20
+ // Static names group each kind of workflow storage transaction in SQLite profiles.
21
+ const WORKFLOW_BATCH_TRANSACTION_NAME = "rivetkit-workflow-batch";
22
+ const WORKFLOW_DELETE_TRANSACTION_NAME = "rivetkit-workflow-delete";
20
23
 
21
24
  // Mirrors the element shape returned by `queueManager.receive`. The actor
22
25
  // instance is reached through a loose type here, so the call's result is
@@ -165,15 +168,18 @@ class WorkflowStorage {
165
168
  async batch(writes: KVWrite[]): Promise<void> {
166
169
  if (writes.length === 0) return;
167
170
  for (const chunk of chunkWorkflowWrites(writes)) {
168
- await this.#db.transaction(async (tx) => {
169
- for (const { key, value } of chunk) {
170
- await tx.execute(
171
- "INSERT INTO _rivet_wf_kv (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
172
- makeWorkflowKey(key),
173
- value,
174
- );
175
- }
176
- });
171
+ await this.#db.transaction(
172
+ async (tx) => {
173
+ for (const { key, value } of chunk) {
174
+ await tx.execute(
175
+ "INSERT INTO _rivet_wf_kv (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",
176
+ makeWorkflowKey(key),
177
+ value,
178
+ );
179
+ }
180
+ },
181
+ { name: WORKFLOW_BATCH_TRANSACTION_NAME },
182
+ );
177
183
  }
178
184
  }
179
185
 
@@ -201,17 +207,20 @@ class WorkflowStorage {
201
207
  start < keys.length;
202
208
  start += WORKFLOW_SQLITE_MAX_BATCH_ROWS
203
209
  ) {
204
- await this.#db.transaction(async (tx) => {
205
- for (const key of keys.slice(
206
- start,
207
- start + WORKFLOW_SQLITE_MAX_BATCH_ROWS,
208
- )) {
209
- await tx.execute(
210
- "DELETE FROM _rivet_wf_kv WHERE key = ?",
211
- key,
212
- );
213
- }
214
- });
210
+ await this.#db.transaction(
211
+ async (tx) => {
212
+ for (const key of keys.slice(
213
+ start,
214
+ start + WORKFLOW_SQLITE_MAX_BATCH_ROWS,
215
+ )) {
216
+ await tx.execute(
217
+ "DELETE FROM _rivet_wf_kv WHERE key = ?",
218
+ key,
219
+ );
220
+ }
221
+ },
222
+ { name: WORKFLOW_DELETE_TRANSACTION_NAME },
223
+ );
215
224
  }
216
225
  }
217
226
  }