@serfab/cadre-core 1.19.0 → 1.20.0

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 (131) hide show
  1. package/dist/cadre-node.d.ts +118 -16
  2. package/dist/cadre-node.js +210 -31
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/control-database.d.ts +2 -1
  5. package/dist/control-database.js +128 -126
  6. package/dist/control-database.js.map +1 -1
  7. package/dist/control-protocol-guard.js +3 -2
  8. package/dist/control-protocol-guard.js.map +1 -1
  9. package/dist/control-read-retry.d.ts +19 -16
  10. package/dist/control-read-retry.js +22 -54
  11. package/dist/control-read-retry.js.map +1 -1
  12. package/dist/control-retry.d.ts +50 -6
  13. package/dist/control-retry.js +53 -6
  14. package/dist/control-retry.js.map +1 -1
  15. package/dist/control-stream.js +2 -1
  16. package/dist/control-stream.js.map +1 -1
  17. package/dist/control-write-retry.d.ts +24 -16
  18. package/dist/control-write-retry.js +58 -30
  19. package/dist/control-write-retry.js.map +1 -1
  20. package/dist/describe-thrown.d.ts +12 -0
  21. package/dist/describe-thrown.js +59 -0
  22. package/dist/describe-thrown.js.map +1 -0
  23. package/dist/edge-node/config.d.ts +8 -2
  24. package/dist/edge-node/config.js +5 -1
  25. package/dist/edge-node/config.js.map +1 -1
  26. package/dist/edge-node/dissolve.d.ts +1 -1
  27. package/dist/edge-node/dissolve.js +1 -1
  28. package/dist/edge-node/dissolve.js.map +1 -1
  29. package/dist/edge-node/edge-join.js +4 -1
  30. package/dist/edge-node/edge-join.js.map +1 -1
  31. package/dist/edge-node/edge-node.d.ts +10 -0
  32. package/dist/edge-node/edge-node.js +54 -9
  33. package/dist/edge-node/edge-node.js.map +1 -1
  34. package/dist/edge-node/options.d.ts +11 -2
  35. package/dist/edge-node/options.js +11 -4
  36. package/dist/edge-node/options.js.map +1 -1
  37. package/dist/edge-node/platform.d.ts +15 -3
  38. package/dist/edge-node/strand-move.d.ts +0 -2
  39. package/dist/edge-node/strand-move.js +1 -4
  40. package/dist/edge-node/strand-move.js.map +1 -1
  41. package/dist/edge-node/strands.js +5 -3
  42. package/dist/edge-node/strands.js.map +1 -1
  43. package/dist/enrollment.js +2 -1
  44. package/dist/enrollment.js.map +1 -1
  45. package/dist/index.d.ts +6 -2
  46. package/dist/index.js +9 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/member-redemption.js +3 -9
  49. package/dist/member-redemption.js.map +1 -1
  50. package/dist/node-local-snapshot.js +2 -1
  51. package/dist/node-local-snapshot.js.map +1 -1
  52. package/dist/peer-dial.js +3 -2
  53. package/dist/peer-dial.js.map +1 -1
  54. package/dist/pending-join-runner.d.ts +29 -2
  55. package/dist/pending-join-runner.js +60 -20
  56. package/dist/pending-join-runner.js.map +1 -1
  57. package/dist/push-notifier-apns.js +8 -7
  58. package/dist/push-notifier-apns.js.map +1 -1
  59. package/dist/push-notifier-fcm.js +6 -5
  60. package/dist/push-notifier-fcm.js.map +1 -1
  61. package/dist/push-notifier-shared.d.ts +0 -2
  62. package/dist/push-notifier-shared.js +4 -4
  63. package/dist/push-notifier-shared.js.map +1 -1
  64. package/dist/relay-reservation.js +4 -3
  65. package/dist/relay-reservation.js.map +1 -1
  66. package/dist/strand-addr-protocol.js +2 -1
  67. package/dist/strand-addr-protocol.js.map +1 -1
  68. package/dist/strand-app-schema-report.d.ts +53 -0
  69. package/dist/strand-app-schema-report.js +77 -0
  70. package/dist/strand-app-schema-report.js.map +1 -0
  71. package/dist/strand-database.d.ts +60 -0
  72. package/dist/strand-database.js +93 -0
  73. package/dist/strand-database.js.map +1 -1
  74. package/dist/strand-first-sync-gate.js +4 -3
  75. package/dist/strand-first-sync-gate.js.map +1 -1
  76. package/dist/strand-formation-protocol.js +4 -3
  77. package/dist/strand-formation-protocol.js.map +1 -1
  78. package/dist/strand-instance-manager.d.ts +73 -2
  79. package/dist/strand-instance-manager.js +112 -9
  80. package/dist/strand-instance-manager.js.map +1 -1
  81. package/dist/strand-membership-reconciler.d.ts +13 -1
  82. package/dist/strand-membership-reconciler.js +25 -16
  83. package/dist/strand-membership-reconciler.js.map +1 -1
  84. package/dist/strand-membership-writer.d.ts +16 -2
  85. package/dist/strand-membership-writer.js +54 -8
  86. package/dist/strand-membership-writer.js.map +1 -1
  87. package/dist/strand-move.js +4 -6
  88. package/dist/strand-move.js.map +1 -1
  89. package/dist/strand-offline.d.ts +102 -0
  90. package/dist/strand-offline.js +97 -0
  91. package/dist/strand-offline.js.map +1 -0
  92. package/dist/types.d.ts +37 -0
  93. package/dist/types.js.map +1 -1
  94. package/package.json +8 -8
  95. package/src/cadre-node.ts +230 -31
  96. package/src/control-database.ts +5594 -5592
  97. package/src/control-protocol-guard.ts +3 -2
  98. package/src/control-read-retry.ts +22 -58
  99. package/src/control-retry.ts +54 -6
  100. package/src/control-stream.ts +2 -1
  101. package/src/control-write-retry.ts +58 -30
  102. package/src/describe-thrown.ts +60 -0
  103. package/src/edge-node/config.ts +11 -2
  104. package/src/edge-node/dissolve.ts +2 -1
  105. package/src/edge-node/edge-join.ts +2 -1
  106. package/src/edge-node/edge-node.ts +57 -7
  107. package/src/edge-node/options.ts +20 -4
  108. package/src/edge-node/platform.ts +15 -3
  109. package/src/edge-node/strand-move.ts +1 -5
  110. package/src/edge-node/strands.ts +74 -72
  111. package/src/enrollment.ts +2 -1
  112. package/src/index.ts +27 -1
  113. package/src/member-redemption.ts +3 -9
  114. package/src/node-local-snapshot.ts +2 -1
  115. package/src/peer-dial.ts +605 -604
  116. package/src/pending-join-runner.ts +68 -22
  117. package/src/push-notifier-apns.ts +8 -7
  118. package/src/push-notifier-fcm.ts +6 -5
  119. package/src/push-notifier-shared.ts +5 -5
  120. package/src/relay-reservation.ts +1212 -1211
  121. package/src/strand-addr-protocol.ts +2 -1
  122. package/src/strand-app-schema-report.ts +115 -0
  123. package/src/strand-database.ts +123 -1
  124. package/src/strand-first-sync-gate.ts +600 -599
  125. package/src/strand-formation-protocol.ts +4 -3
  126. package/src/strand-instance-manager.ts +137 -10
  127. package/src/strand-membership-reconciler.ts +942 -928
  128. package/src/strand-membership-writer.ts +61 -14
  129. package/src/strand-move.ts +594 -597
  130. package/src/strand-offline.ts +178 -0
  131. package/src/types.ts +36 -0
@@ -37,6 +37,7 @@ import { decodeLengthPrefixedFrame } from './seed-bootstrap.js';
37
37
  import { orderSignalingFirst } from './peer-record.js';
38
38
  import { type ControlStream, withDeadline, exchangeFrame, readStreamToEnd, replyAndClose } from './control-stream.js';
39
39
  import { relayedRequestBudgetMs } from './link-budget.js';
40
+ import { toError } from './describe-thrown.js';
40
41
 
41
42
  const log = debug('sereus:cadre:strand-addr');
42
43
 
@@ -417,7 +418,7 @@ async function dialOneSibling(
417
418
  );
418
419
  return siblingAnswer(response);
419
420
  } catch (err) {
420
- const error = err instanceof Error ? err : new Error(String(err));
421
+ const error = toError(err);
421
422
  // Matched by name, as libp2p's own error classes are compared across package copies.
422
423
  if (error.name === 'UnsupportedProtocolError') {
423
424
  log('Strand-addr refused by %s via %s: it does not serve %s', peer.peerId, describeTarget(target), protocolId);
@@ -0,0 +1,115 @@
1
+ import debug from 'debug';
2
+ import { toError } from './describe-thrown.js';
3
+ import type { AppSchemaOutcome, AppSchemaWait, SereusPluginResult } from '@serfab/quereus-plugin-sereus';
4
+
5
+ const log = debug('sereus:cadre:strand-app-schema');
6
+
7
+ /**
8
+ * `StrandDatabase.appSchemaState()`: whether the database runs the `App` schema its launch was
9
+ * given. While the apply is held back the database runs the earlier schema: `'waiting-for-queue'`
10
+ * while queued offline transactions refuse it, `'waiting-for-cohort'` while the strand's members
11
+ * cannot be reached. `'failed'` when a later retry failed for another reason.
12
+ */
13
+ export type StrandAppSchemaState = 'applied' | 'waiting-for-queue' | 'waiting-for-cohort' | 'failed';
14
+
15
+ /** `strand:app-schema-deferred`: why the `App` schema apply was held back. */
16
+ export interface StrandAppSchemaDeferred {
17
+ readonly strandId: string;
18
+ /** `'queue'`: queued offline transactions refused it. `'cohort'`: the strand's members could not be reached. */
19
+ readonly waitingFor: AppSchemaWait;
20
+ /** The queued transactions that refused it; empty when {@link waitingFor} is `'cohort'`. */
21
+ readonly transactionIds: readonly string[];
22
+ }
23
+
24
+ /**
25
+ * Where a strand database reports its `App` schema apply. Retained with the launch config and handed
26
+ * to every database built for the launch, so the reports outlive hibernation and every other rebuild.
27
+ */
28
+ export interface StrandAppSchemaListeners {
29
+ onAppSchemaDeferred?: (event: StrandAppSchemaDeferred) => void;
30
+ onAppSchemaApplied?: (event: { strandId: string }) => void;
31
+ onAppSchemaFailed?: (event: { strandId: string; error: Error }) => void;
32
+ }
33
+
34
+ const WAITING_STATE: Record<AppSchemaWait, StrandAppSchemaState> = {
35
+ queue: 'waiting-for-queue',
36
+ cohort: 'waiting-for-cohort'
37
+ };
38
+
39
+ /**
40
+ * What one strand database reports about its `App` schema apply. Built once `connectToStrand` has
41
+ * returned and released first when the database closes, so nothing from a closing connection reaches
42
+ * the app. Events begin at publication, when the app gets the database: a retry that landed before
43
+ * then is not announced, and one that failed before then is announced at publication.
44
+ */
45
+ export class StrandAppSchemaReport {
46
+ private state: StrandAppSchemaState;
47
+ private error: Error | undefined;
48
+ private wasPublished = false;
49
+ private released = false;
50
+
51
+ constructor(
52
+ private readonly strandId: string,
53
+ private readonly listeners: StrandAppSchemaListeners,
54
+ private readonly result: Pick<SereusPluginResult, 'appSchema' | 'appSchemaWaitingFor' | 'appSchemaDeferredBy'>
55
+ ) {
56
+ // `appSchema` is absent without an `App` schema (a storage replica), which has nothing to defer.
57
+ const waitingFor = result.appSchemaWaitingFor;
58
+ this.state = waitingFor ? WAITING_STATE[waitingFor] : 'applied';
59
+ if (waitingFor) {
60
+ void result.appSchema?.then((outcome) => this.settle(outcome)).catch((error: unknown) => {
61
+ log('strand %s: reporting the deferred app schema apply failed: %O', strandId, error);
62
+ });
63
+ }
64
+ }
65
+
66
+ appSchemaState(): StrandAppSchemaState {
67
+ return this.state;
68
+ }
69
+
70
+ /** The database was handed to the app: report an apply still waiting or already failed. */
71
+ published(): void {
72
+ if (this.released || this.wasPublished) {
73
+ return;
74
+ }
75
+ this.wasPublished = true;
76
+ const waitingFor = this.result.appSchemaWaitingFor;
77
+ if (waitingFor && this.state === WAITING_STATE[waitingFor]) {
78
+ this.listeners.onAppSchemaDeferred?.({
79
+ strandId: this.strandId,
80
+ waitingFor,
81
+ transactionIds: this.result.appSchemaDeferredBy ?? []
82
+ });
83
+ } else if (this.error) {
84
+ this.reportFailed(this.error);
85
+ }
86
+ }
87
+
88
+ release(): void {
89
+ this.released = true;
90
+ }
91
+
92
+ /** A cancelled retry (the database closed first) reports nothing. */
93
+ private settle(outcome: AppSchemaOutcome): void {
94
+ if (this.released || outcome.state === 'cancelled') {
95
+ return;
96
+ }
97
+ if (outcome.state === 'applied') {
98
+ this.state = 'applied';
99
+ if (this.wasPublished) {
100
+ this.listeners.onAppSchemaApplied?.({ strandId: this.strandId });
101
+ }
102
+ return;
103
+ }
104
+ this.state = 'failed';
105
+ this.error = toError(outcome.error);
106
+ log('strand %s: the deferred app schema apply failed; the database keeps the earlier schema: %O', this.strandId, outcome.error);
107
+ if (this.wasPublished) {
108
+ this.reportFailed(this.error);
109
+ }
110
+ }
111
+
112
+ private reportFailed(error: Error): void {
113
+ this.listeners.onAppSchemaFailed?.({ strandId: this.strandId, error });
114
+ }
115
+ }
@@ -1,9 +1,10 @@
1
1
  import debug from 'debug';
2
2
  import { Database } from '@quereus/quereus';
3
3
  import { applyAppSchema, connectToStrand } from '@serfab/quereus-plugin-sereus';
4
- import type { SereusPluginResult } from '@serfab/quereus-plugin-sereus';
4
+ import type { SereusPluginResult, StrandOfflineController } from '@serfab/quereus-plugin-sereus';
5
5
  import type { Libp2p } from '@libp2p/interface';
6
6
  import type { IRepo } from '@optimystic/db-core';
7
+ import type { IKVStore } from '@optimystic/db-p2p';
7
8
  import type { SAppConfig } from './types.js';
8
9
  import { bootstrapFounderMembership } from './strand-membership-writer.js';
9
10
  import { strandMemberKeyPair } from './strand-member-key.js';
@@ -11,6 +12,9 @@ import { StrandCommitRecord } from './strand-commit-durability.js';
11
12
  import type { StrandCommitDurability, StrandCommitListeners } from './strand-commit-durability.js';
12
13
  import { TableWatchRegistry } from './table-change-watch.js';
13
14
  import type { TableChangeWatch, TableChangeWatchOptions } from './table-change-watch.js';
15
+ import { discardQueued, StrandOfflineReport } from './strand-offline.js';
16
+ import type { StrandOfflineListeners, StrandOfflineMode, StrandOfflineQueue } from './strand-offline.js';
17
+ import { StrandAppSchemaReport, type StrandAppSchemaListeners, type StrandAppSchemaState } from './strand-app-schema-report.js';
14
18
 
15
19
  const log = debug('sereus:cadre:strand-db');
16
20
  const timing = debug('sereus:cadre:timing');
@@ -64,6 +68,27 @@ export interface StrandDatabaseConfig extends StrandCommitListeners {
64
68
  * fixture that hand-drives the membership writers sees only the rows it wrote. Defaults to false.
65
69
  */
66
70
  bindFounderPeer?: boolean;
71
+ /**
72
+ * Turn on the connection's offline queue (docs/strands.md → "Offline mode"). Absent: no queue,
73
+ * and {@link StrandDatabase.offline} is undefined.
74
+ */
75
+ offline?: StrandDatabaseOffline;
76
+ /** Where to report the `App` schema apply when it is held back (docs/strands.md → "An app schema upgrade waits for the queue or the cohort"). */
77
+ appSchema?: StrandAppSchemaListeners;
78
+ }
79
+
80
+ /** {@link StrandDatabaseConfig.offline}: one build's journal, the strand's mode, and where to report. */
81
+ export interface StrandDatabaseOffline extends StrandOfflineListeners {
82
+ /**
83
+ * This build's journal, resolved by {@link StrandDatabase.initialize}, so a launch released while
84
+ * it resolves is caught like one released during the rest of the build. A throw fails initialize.
85
+ */
86
+ journal: () => IKVStore | Promise<IKVStore>;
87
+ /**
88
+ * The strand's mode, read at the end of {@link StrandDatabase.initialize} and at every
89
+ * {@link StrandDatabase.applyOfflineMode}, never captured, so the newest choice wins.
90
+ */
91
+ mode: () => StrandOfflineMode;
67
92
  }
68
93
 
69
94
  /**
@@ -91,6 +116,9 @@ export class StrandDatabase {
91
116
  private initialized = false;
92
117
  private readonly commits: StrandCommitRecord;
93
118
  private unsubscribeCommits: (() => void) | null = null;
119
+ private offlineQueue: StrandOfflineController | null = null;
120
+ private offlineReport: StrandOfflineReport | null = null;
121
+ private appSchemaReport: StrandAppSchemaReport | null = null;
94
122
  /** Subscriptions handed out by {@link watchTables}. */
95
123
  private readonly tableWatches = new TableWatchRegistry();
96
124
 
@@ -120,6 +148,7 @@ export class StrandDatabase {
120
148
  log('Initializing StrandDatabase for strand: %s (%s)', sid,
121
149
  sAppConfig ? `sApp: ${sAppConfig.id} v${sAppConfig.version}` : 'storage replica');
122
150
 
151
+ const offline = this.config.offline && { journal: await this.config.offline.journal() };
123
152
  this.db = new Database();
124
153
 
125
154
  // Delegate to the shared composition. The node is injected, so:
@@ -141,12 +170,15 @@ export class StrandDatabase {
141
170
  libp2pNode: this.config.libp2pNode,
142
171
  coordinatedRepo: this.config.coordinatedRepo,
143
172
  enableCache: true,
173
+ offline,
144
174
  });
145
175
  this.shutdownStrand = result.shutdown;
146
176
  this.resolvedTransactor = result.transactor;
147
177
  this.createEmptyCollections = result.createEmptyCollections;
148
178
  // Before the founder bootstrap, so its commits are reported like any other.
149
179
  this.subscribeToCommits(result);
180
+ this.followOffline(result);
181
+ this.appSchemaReport = new StrandAppSchemaReport(sid, this.config.appSchema ?? {}, result);
150
182
  timing('[strandDb:%s] connectToStrand: %dms (hydrated tables=%d, indexes=%d)',
151
183
  sid, Math.round(performance.now() - t0),
152
184
  result.hydrated?.tables ?? 0, result.hydrated?.indexes ?? 0);
@@ -155,10 +187,20 @@ export class StrandDatabase {
155
187
  // applied (connectToStrand has returned). A throw here propagates out of
156
188
  // initialize(), and the caller closes this half-built database (close() runs the
157
189
  // composition's shutdown). Joiners skip this — their rows arrive via sync.
190
+ // NOTE: a bootstrap with rows to write while `hydrate` restored queued transactions is refused
191
+ // (`StrandOfflineQueueBusyError`), failing every build, so that queue could never drain. Not
192
+ // reachable today: rows are written only while the founding is incomplete (Member empty, or no
193
+ // Manager and none retired), and an incomplete founding fails the build before the database is
194
+ // ever published for the app to queue in. If a founder is ever published with its founding
195
+ // incomplete, skip the bootstrap here while the queue is non-empty and run it once the queue drains.
158
196
  if (this.config.founder === true) {
159
197
  await this.bootstrapFounder();
160
198
  }
161
199
 
200
+ // After `hydrate` restored the queue and after the founder bootstrap (its `Strand` writes are
201
+ // network-acknowledged in either mode); before the first-sync probe, so in offline mode a read
202
+ // the cohort cannot answer is served from this machine's copy there as it is to the app.
203
+ this.applyOfflineMode();
162
204
  this.initialized = true;
163
205
  log('StrandDatabase for strand %s initialized successfully', sid);
164
206
  }
@@ -172,6 +214,42 @@ export class StrandDatabase {
172
214
  };
173
215
  }
174
216
 
217
+ private followOffline(result: SereusPluginResult): void {
218
+ const { offline } = this.config;
219
+ if (!offline) {
220
+ return;
221
+ }
222
+ this.offlineQueue = result.offline ?? null;
223
+ this.offlineReport = new StrandOfflineReport(this.config.strandId, offline, result.offline);
224
+ }
225
+
226
+ /**
227
+ * Put the queue in the strand's current mode ({@link StrandDatabaseOffline.mode}). It sets the
228
+ * acknowledgement of transactions begun from now on; an open one keeps the one it began with.
229
+ * No-op without a queue, and before {@link initialize} has composed one (it applies the mode itself).
230
+ */
231
+ applyOfflineMode(): void {
232
+ const queue = this.offlineQueue;
233
+ if (!queue || !this.config.offline) {
234
+ return;
235
+ }
236
+ if (this.config.offline.mode() === 'offline') {
237
+ queue.enter();
238
+ } else {
239
+ queue.exit();
240
+ }
241
+ }
242
+
243
+ /**
244
+ * The database was handed to the app (`StrandInstanceManager.publishDatabase`): report the
245
+ * queue's state, since restored transactions' `queued` statuses were delivered before anything
246
+ * subscribed, and an `App` schema apply still held back.
247
+ */
248
+ reportPublished(): void {
249
+ this.offlineReport?.published();
250
+ this.appSchemaReport?.published();
251
+ }
252
+
175
253
  /**
176
254
  * Run the founder membership bootstrap against the freshly-composed strand DB.
177
255
  *
@@ -268,6 +346,10 @@ export class StrandDatabase {
268
346
  */
269
347
  async attachAppSchema(sAppConfig: SAppConfig): Promise<void> {
270
348
  this.ensureInitialized();
349
+ // NOTE: unlike the connect-time apply (`applyAppSchemaAfterQueue`), this is not deferred behind
350
+ // the offline queue: a replica writes no app transactions, so no queued transaction wrote an
351
+ // `App` table and `QueuedEntriesBlockSchemaChangeError` cannot refuse it. If a replica ever
352
+ // writes app rows offline, route this through the deferral instead of throwing.
271
353
  await applyAppSchema(this.db!, sAppConfig.schema);
272
354
  this.config.sAppConfig = sAppConfig;
273
355
  log('StrandDatabase for strand %s attached sApp %s v%s', this.config.strandId, sAppConfig.id, sAppConfig.version);
@@ -306,6 +388,41 @@ export class StrandDatabase {
306
388
  return this.commits.get(transactionId);
307
389
  }
308
390
 
391
+ /**
392
+ * The strand connection's offline queue (docs/strands.md → "Offline mode"), or `undefined` on a
393
+ * node without `strandOffline`. The mode is set through `CadreNode.setStrandOfflineMode`, which
394
+ * outlives this database; listeners taken here die with it, as {@link watchTables} subscriptions do.
395
+ */
396
+ get offline(): StrandOfflineQueue | undefined {
397
+ this.ensureInitialized();
398
+ return this.offlineQueue ?? undefined;
399
+ }
400
+
401
+ /**
402
+ * Whether this database runs the `App` schema its launch was given. `'waiting-for-queue'` or
403
+ * `'waiting-for-cohort'` while the apply is held back, so `StrandInstance.sAppInfo` names a version
404
+ * whose new tables or columns are not here yet; check this before relying on them.
405
+ */
406
+ appSchemaState(): StrandAppSchemaState {
407
+ this.ensureInitialized();
408
+ return this.appSchemaReport?.appSchemaState() ?? 'applied';
409
+ }
410
+
411
+ /**
412
+ * The transaction ids the offline queue lists (`entries()`, the ones a restore has not put back
413
+ * yet included), or `undefined` with no queue: none configured, not composed yet, or closed.
414
+ * Unlike {@link offline} it does not require {@link initialize} to have finished, so the manager
415
+ * can read a database still being built or about to close.
416
+ */
417
+ queuedTransactionIds(): readonly string[] | undefined {
418
+ return this.offlineQueue?.entries().map((entry) => entry.transactionId);
419
+ }
420
+
421
+ /** {@link discardQueued} on this database's queue; `undefined` with no queue, as {@link queuedTransactionIds}. */
422
+ discardQueuedTransactions(): readonly string[] | undefined {
423
+ return this.offlineQueue ? discardQueued(this.offlineQueue) : undefined;
424
+ }
425
+
309
426
  /**
310
427
  * The Optimystic transactor this strand's connection resolved to — always
311
428
  * `'network'` here, since cadre-core passes no `transactor` option and takes
@@ -328,6 +445,11 @@ export class StrandDatabase {
328
445
  // First, so an event from the closing connection reaches no app handler or table watch.
329
446
  this.unsubscribeCommits?.();
330
447
  this.unsubscribeCommits = null;
448
+ this.offlineReport?.release();
449
+ this.offlineReport = null;
450
+ this.appSchemaReport?.release();
451
+ this.appSchemaReport = null;
452
+ this.offlineQueue = null;
331
453
  this.tableWatches.disposeAll();
332
454
  if (this.shutdownStrand) {
333
455
  await this.shutdownStrand();