Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

hydration-commit.opfs.ts

695 lines24.0 KB

1/**
2 * Receiving witness for persisted-oracle.test.ts's source durability laws.
3 * Chromium OPFS supplies the actual scheduler, worker, SQL and durable state.
4 * Startup/subscription/after-ready histories cross default/browser coordinators,
5 * empty/populated storage and a single insert/rich replacement history. Three
6 * Collections have distinct schemas: A commits within hydration, B hydrates
7 * behind it, and already-ready C requests ordinary durability during A's hold.
8 *
9 * The spec computes rows/metadata from the declared history, independently of
10 * this driver. A real row SELECT supplies the held-read premise. Its exact
11 * scope is retained only as a diagnostic identity, never used for storage.
12 * Coordinator instrumentation associates each nested transaction with the
13 * supplied live scope before detecting a scheduled public-adapter call. Thus
14 * an unrelated regular operation overlapping hydration is not called a cycle.
15 * All calls still reach production unchanged.
16 *
17 * Comparison cuts are held read, actual nested routing, and completed receipts,
18 * exact owning-scope exit (16 held-read histories), peer readiness, durable
19 * reads, and reopen. Eight after-ready controls have no held owning scope. Cleanup
20 * copies the primary observation first and records each secondary failure;
21 * page disposal owns remaining JS resources if the production cycle is red.
22 * Other browsers, multi-tab election, physical I/O failures, arbitrary fairness
23 * storms and cancellation remain with their existing owners.
24 */
25import { createCollection } from '../../db/src/index'
26import {
27 BrowserCollectionCoordinator,
28 createBrowserWASQLitePersistence,
29 openBrowserWASQLiteOPFSDatabase,
30 persistedCollectionOptions,
31} from '../src/index'
32import type { Collection, SyncConfig } from '../../db/src/index'
33import type { HydrationPersistenceAdapter } from '../../db-sqlite-persistence-core/src/index'
34​
35type Row = { id: string; value: number }
36type Phase = `startup` | `subscription` | `after-ready`
37type Receipt = `pending` | `fulfilled` | `rejected`
38export type HydrationCommitObservation = {
39 phase: Phase
40 baseline: boolean
41 rich: boolean
42 browserCoordinator: boolean
43 sourceStorageId: string
44 rowReads: number
45 cycleCalls: number
46 held: {
47 receipts: Array<Receipt>
48 rows: Array<Row>
49 ordinary: Receipt
50 interleavedSql: Array<string>
51 peerHydrationAdmitted: boolean
52 ordinaryAdmitted: boolean
53 } | null
54 receipts: Array<Receipt>
55 sourceStatus: string
56 peerStatus: string
57 ordinaryReceipt: Receipt
58 owningScopeExited: boolean | null
59 tailScheduling: Array<`public-apply` | `regular-scope`>
60 peerWorkBeforeScopeExit: Array<string>
61 ordinaryCommitSqlCalls: number
62 rows: Array<Row>
63 durableRows: Array<Row> | null
64 durableMetadata: Array<{ key: string; value: unknown }> | null
65 durableRowMetadata: Array<{ key: string | number; metadata: unknown }> | null
66 peerRows: Array<Row> | null
67 ordinaryRows: Array<Row> | null
68 schemas: Array<{ collection_id: string; schema_version: number }> | null
69 reopenedRows: Array<Row> | null
70 errors: Array<string>
72declare global {
73 interface Window {
74 __hydrationCommitResult?: HydrationCommitObservation
75 __hydrationCommitError?: string
76 __hydrationCommitCleanupErrors?: Array<string>
77 __hydrationCommitDone?: boolean
78 }
80function deferred() {
81 let resolve!: () => void
82 const promise = new Promise<void>((settle) => {
83 resolve = settle
84 })
85 return { promise, resolve }
87function publicRows(collection: Collection<Row, string>): Array<Row> {
88 return [...collection.values()]
89 .map(({ id, value }) => ({ id, value }))
90 .sort((a, b) => a.id.localeCompare(b.id))
92async function run(): Promise<void> {
93 const params = new URL(location.href).searchParams
94 const phase = params.get(`phase`) as Phase
95 if (![`startup`, `subscription`, `after-ready`].includes(phase))
96 throw new Error(`Invalid phase`)
97 const baseline = params.get(`baseline`) === `true`
98 const rich = params.get(`rich`) === `true`
99 const browserCoordinator = params.get(`coordinator`) === `browser`
100 const databaseName = `hc-${crypto.randomUUID()}.sqlite`
101 const database = await openBrowserWASQLiteOPFSDatabase({ databaseName })
102 const cleanup: Array<() => void | Promise<unknown>> = []
103 const cleanupErrors: Array<string> = []
104 const releaseRead = deferred()
105 let disposeCoordinator: (() => void) | undefined
106 let captured: HydrationCommitObservation | undefined
107 let cycleCalls = 0
108 try {
109 const coordinator = browserCoordinator
110 ? new BrowserCollectionCoordinator({ dbName: databaseName })
111 : undefined
112 if (coordinator) disposeCoordinator = () => coordinator.dispose()
113 const readEntered = deferred()
114 const cycle = deferred()
115 const sourceStarted = deferred()
116 const sourceReady = deferred()
117 const peerReady = deferred()
118 const scopeExited = deferred()
119 const peerHydrationAdmission = deferred()
120 const ordinaryAdmission = deferred()
121 let observeContenders = false
122 let peerHydrationAdmitted = false
123 let ordinaryAdmitted = false
124 let scopePremiseError: Error | undefined
125 let holdRead = false
126 let readHeld = false
127 const interleavedSql: Array<string> = []
128 let rowReads = 0
129 let scopeSequence = 0
130 let heldScope: number | undefined
131 let owningScopeExited: boolean | null =
132 phase === `after-ready` ? null : false
133 const liveScopes = new Map<number, HydrationPersistenceAdapter>()
134 let ordinaryCommitSqlCalls = 0
135 const peerWorkBeforeScopeExit: Array<string> = []
136 const observePeerWork = (operation: string) => {
137 if (heldScope !== undefined && liveScopes.has(heldScope)) {
138 peerWorkBeforeScopeExit.push(operation)
139 }
140 }
141 const persistence = createBrowserWASQLitePersistence({
142 database: {
143 execute: async <T>(sql: string, bindings?: ReadonlyArray<unknown>) => {
144 if (readHeld) interleavedSql.push(sql)
145 // Every ordinary apply reads its applied_tx/version state before
146 // writing. Observe C at that real SQL boundary, through scope exit.
147 // Election stream-position reads intentionally bypass this scheduler
148 // and are not regular work (getStreamPosition's existing contract).
149 if (sql.includes(`AS already_applied`) && bindings?.includes(`c`)) {
150 ordinaryCommitSqlCalls++
151 observePeerWork(`ordinary-commit-sql`)
152 }
153 const result = await database.execute<T>(sql, bindings)
154 if (sql.includes(`SELECT key, value, metadata, row_version FROM`)) {
155 rowReads++
156 if (holdRead) {
157 holdRead = false
158 // Public A scopes are serialized by the real shared scheduler.
159 // Key by callback invocation, since SQLite reuses its loan object.
160 // An invalid premise fails here instead of waiting for a lost exit.
161 if (liveScopes.size !== 1) {
162 scopePremiseError = new Error(
163 `Held read requires exactly one owning callback; got ${liveScopes.size}`,
164 )
165 readEntered.resolve()
166 throw scopePremiseError
167 }
168 heldScope = liveScopes.keys().next().value
169 readHeld = true
170 readEntered.resolve()
171 await releaseRead.promise
172 readHeld = false
173 }
174 }
175 return result
176 },
177 },
178 ...(coordinator ? { coordinator } : {}),
179 })
180 const resolved = persistence.resolvePersistenceForCollection!({
181 collectionId: `a`,
182 mode: `sync-present`,
183 schemaVersion: 11,
184 })
185 const adapter = resolved.adapter
186 // On-demand A writes its claimed physical cache ID. Keep that ID from the
187 // adapter's claim result so the scheduling and durable checks observe the
188 // same Collection without guessing a storage-name format.
189 let sourceStorageId = `a`
190 let sourceClaimId: string | undefined
191 if (phase === `subscription`) {
192 const claim = adapter.claimCacheGeneration?.bind(adapter)
193 if (!claim) throw new Error(`On-demand A requires a managed cache claim`)
194 adapter.claimCacheGeneration = async (id) => {
195 const result = await claim(id)
196 if (id === `a`) {
197 sourceStorageId = result.storageCollectionId
198 sourceClaimId = result.claimId
199 }
200 return result
201 }
202 }
203 const bAdapter = persistence.resolvePersistenceForCollection!({
204 collectionId: `b`,
205 mode: `sync-present`,
206 schemaVersion: 22,
207 }).adapter
208 const cAdapter = persistence.resolvePersistenceForCollection!({
209 collectionId: `c`,
210 mode: `sync-present`,
211 schemaVersion: 33,
212 }).adapter
213 const seed = (id: string, row: Row, target: typeof adapter) =>
214 target.applyCommittedTx(
215 { kind: `eager`, collectionId: id },
216 {
217 txId: `seed-${id}`,
218 term: 1,
219 seq: 1,
220 rowVersion: 1,
221 mutations: [{ type: `insert`, key: row.id, value: row }],
222 },
223 )
224 if (baseline && phase === `subscription`) {
225 const claim = await adapter.claimCacheGeneration!(`a`)
226 await adapter.applyCommittedTx(
227 {
228 kind: `managed`,
229 storageCollectionId: claim.storageCollectionId,
230 claimId: claim.claimId,
231 },
232 {
233 txId: `seed-a`,
234 term: 1,
235 seq: 1,
236 rowVersion: 1,
237 cacheGenerationClaimId: claim.claimId,
238 mutations: [
239 {
240 type: `insert`,
241 key: `baseline`,
242 value: { id: `baseline`, value: 0 },
243 },
244 ],
245 },
246 )
247 await adapter.releaseCacheGenerationClaim!(claim.claimId)
248 } else if (baseline) {
249 await seed(`a`, { id: `baseline`, value: 0 }, adapter)
250 }
251 await seed(`b`, { id: `peer-baseline`, value: 22 }, bAdapter)
252 const runScope = adapter.runInHydrationScope!.bind(adapter)
253 const pendingHydrations = new Set<Promise<unknown>>()
254 adapter.runInHydrationScope = (task) => {
255 const result = runScope(async (scoped) => {
256 const scope = ++scopeSequence
257 liveScopes.set(scope, scoped)
258 try {
259 return await task(scoped)
260 } finally {
261 liveScopes.delete(scope)
262 if (scope === heldScope) {
263 owningScopeExited = true
264 scopeExited.resolve()
265 }
266 }
267 })
268 pendingHydrations.add(result)
269 void result.then(
270 () => pendingHydrations.delete(result),
271 () => pendingHydrations.delete(result),
272 )
273 return result
274 }
275 // Each method enqueues synchronously before returning its promise. Observe
276 // that return without awaiting completion, which is blocked by A's read.
277 const bHydrate = bAdapter.runInHydrationScope!.bind(bAdapter)
278 bAdapter.runInHydrationScope = (task) => {
279 const result = bHydrate((scoped) => {
280 observePeerWork(`peer-hydrate`)
281 return task(scoped)
282 })
283 if (observeContenders) {
284 peerHydrationAdmitted = true
285 peerHydrationAdmission.resolve()
286 }
287 return result
288 }
289 const admitOrdinary = () => {
290 if (observeContenders) {
291 ordinaryAdmitted = true
292 ordinaryAdmission.resolve()
293 }
294 }
295 // Default coordinator uses public apply; browser leadership uses the
296 // regular-scope API before its writer lock. Observe both real entry paths.
297 const cApply = cAdapter.applyCommittedTx.bind(cAdapter)
298 cAdapter.applyCommittedTx = (...args) => {
299 const result = cApply(...args)
300 admitOrdinary()
301 return result
302 }
303 const cScope = cAdapter.runInRegularScope!
304 const cRegular = cScope.bind(cAdapter)
305 cAdapter.runInRegularScope = Object.assign(
306 <T>(task: (adapter: HydrationPersistenceAdapter) => Promise<T>) => {
307 const result = cRegular((scoped) => {
308 observePeerWork(`ordinary-scope`)
309 return task(scoped)
310 })
311 admitOrdinary()
312 return result
313 },
314 { afterQueuedWork: cScope.afterQueuedWork },
315 )
316 const nested = new Set<string>()
317 const tailTransactions = new Set<string>()
318 let tailStarted = false
319 const tailScheduling: HydrationCommitObservation[`tailScheduling`] = []
320 const aScope = adapter.runInRegularScope!
321 const aRegular = aScope.bind(adapter)
322 adapter.runInRegularScope = Object.assign(
323 <T>(task: (adapter: HydrationPersistenceAdapter) => Promise<T>) => {
324 const result = aRegular(task)
325 if (tailStarted && tailTransactions.size > 0)
326 tailScheduling.push(`regular-scope`)
327 return result
328 },
329 { afterQueuedWork: aScope.afterQueuedWork },
330 )
331 const request = resolved.coordinator!.requestApplyCommittedTx.bind(
332 resolved.coordinator!,
333 )
334 resolved.coordinator!.requestApplyCommittedTx = async (id, tx, scoped) => {
335 const nestedHere =
336 id === sourceStorageId &&
337 scoped !== undefined &&
338 [...liveScopes.values()].includes(scoped)
339 if (nestedHere) nested.add(tx.txId)
340 if (id === sourceStorageId && tailStarted) tailTransactions.add(tx.txId)
341 try {
342 return await request(id, tx, scoped)
343 } finally {
344 if (nestedHere) nested.delete(tx.txId)
345 }
346 }
347 const apply = adapter.applyCommittedTx.bind(adapter)
348 adapter.applyCommittedTx = (id, tx) => {
349 const result = apply(id, tx)
350 if (
351 (id.kind === `managed` ? id.storageCollectionId : id.collectionId) ===
352 sourceStorageId &&
353 tailStarted &&
354 tailTransactions.has(tx.txId)
355 )
356 tailScheduling.push(`public-apply`)
357 if (
358 (id.kind === `managed` ? id.storageCollectionId : id.collectionId) ===
359 sourceStorageId &&
360 nested.has(tx.txId)
361 ) {
362 cycleCalls++
363 cycle.resolve()
364 }
365 return result
366 }
367 const errors: Array<string> = []
368 const receiptStates: Array<Receipt> = []
369 const receiptPromises: Array<Promise<void>> = []
370 let source!: Parameters<SyncConfig<Row, string>[`sync`]>[0]
371 const commit = (edit: () => void) => {
372 source.begin()
373 edit()
374 const index = receiptStates.push(`pending`) - 1
375 const receipt = Promise.resolve(source.commit()).then(
376 () => {
377 receiptStates[index] = `fulfilled`
378 },
379 (error: unknown) => {
380 receiptStates[index] = `rejected`
381 errors.push(String(error))
382 },
383 )
384 receiptPromises.push(receipt)
385 }
386 const sourceHistory = () => {
387 commit(() =>
388 source.write({ type: `insert`, value: { id: `r1`, value: 1 } }),
389 )
390 if (!rich) return
391 commit(() => source.metadata!.collection.set(`cursor`, 7))
392 commit(() => {
393 source.metadata!.collection.set(`cursor`, 8)
394 source.truncate()
395 source.write({ type: `insert`, value: { id: `r2`, value: 2 } })
396 source.metadata!.row.set(`r2`, { owner: `source` })
397 })
398 commit(() =>
399 source.write({ type: `update`, value: { id: `r2`, value: 3 } }),
400 )
401 commit(() =>
402 source.write({ type: `insert`, value: { id: `temporary`, value: 4 } }),
403 )
404 commit(() => source.write({ type: `delete`, key: `temporary` }))
405 }
406 let ordinarySource!: Parameters<SyncConfig<Row, string>[`sync`]>[0]
407 const c = createCollection(
408 persistedCollectionOptions<Row, string>({
409 id: `c`,
410 schemaVersion: 33,
411 persistence,
412 getKey: (row) => row.id,
413 sync: {
414 sync: (controls) => {
415 ordinarySource = controls
416 controls.markReady()
417 },
418 },
419 }),
420 )
421 cleanup.unshift(() => c.cleanup())
422 await c.preload()
423 holdRead = phase === `startup`
424 const a = createCollection(
425 persistedCollectionOptions<Row, string>({
426 id: `a`,
427 schemaVersion: 11,
428 persistence,
429 getKey: (row) => row.id,
430 startSync: true,
431 syncMode: phase === `subscription` ? `on-demand` : `eager`,
432 sync: {
433 sync: (controls) => {
434 source = controls
435 if (phase === `startup`) sourceHistory()
436 controls.markReady()
437 sourceStarted.resolve()
438 return { loadSubset: () => true }
439 },
440 },
441 }),
442 )
443 cleanup.unshift(() => a.cleanup())
444 a.onFirstReady(() => {
445 sourceReady.resolve()
446 if (phase === `after-ready`) sourceHistory()
447 })
448 await sourceStarted.promise
449 if (phase === `subscription`) {
450 await sourceReady.promise
451 holdRead = true
452 const subscription = a.subscribeChanges(() => {}, {
453 includeInitialState: true,
454 })
455 cleanup.unshift(() => subscription.unsubscribe())
456 }
457 if (phase !== `after-ready`) await readEntered.promise
458 else {
459 await sourceReady.promise
460 scopeExited.resolve()
461 }
462 if (scopePremiseError) throw scopePremiseError
463 if (phase === `subscription`) sourceHistory()
464 observeContenders = true
465 const b = createCollection(
466 persistedCollectionOptions<Row, string>({
467 id: `b`,
468 schemaVersion: 22,
469 persistence,
470 getKey: (row) => row.id,
471 startSync: true,
472 sync: { sync: ({ markReady }) => markReady() },
473 }),
474 )
475 cleanup.unshift(() => b.cleanup())
476 b.onFirstReady(peerReady.resolve)
477 ordinarySource.begin()
478 ordinarySource.write({
479 type: `insert`,
480 value: { id: `ordinary`, value: 33 },
481 })
482 let ordinaryReceipt: Receipt = `pending`
483 const ordinaryDone = Promise.resolve(ordinarySource.commit()).then(
484 () => {
485 ordinaryReceipt = `fulfilled`
486 },
487 (error: unknown) => {
488 ordinaryReceipt = `rejected`
489 errors.push(String(error))
490 },
491 )
492 // Both contenders have crossed their real scheduling API before the cut.
493 // No task tick or SQL latency is used as evidence of admission.
494 await Promise.all([
495 peerHydrationAdmission.promise,
496 ordinaryAdmission.promise,
497 ])
498 const held =
499 phase === `after-ready`
500 ? null
501 : {
502 receipts: [...receiptStates],
503 rows: publicRows(a),
504 ordinary: ordinaryReceipt,
505 interleavedSql: [...interleavedSql],
506 peerHydrationAdmitted,
507 ordinaryAdmitted,
508 }
509 releaseRead.resolve()
510 await Promise.race([
511 cycle.promise,
512 Promise.all([
513 sourceReady.promise,
514 ...receiptPromises,
515 peerReady.promise,
516 ordinaryDone,
517 scopeExited.promise,
518 ]),
519 ])
520 let durableRows: Array<Row> | null = null
521 let durableMetadata: Array<{ key: string; value: unknown }> | null = null
522 let durableRowMetadata: Array<{
523 key: string | number
524 metadata: unknown
525 }> | null = null
526 let peerRows: Array<Row> | null = null
527 let ordinaryRows: Array<Row> | null = null
528 let schemas: HydrationCommitObservation[`schemas`] = null
529 const reopenedRows: Array<Row> | null = null
530 if (cycleCalls === 0) {
531 // Truncate can trigger a follow-up subset hydrate. Join all public A
532 // invocations already requested by the source history before issuing an
533 // ordinary tail; the originally held callback alone is not quiescence.
534 while (pendingHydrations.size > 0) {
535 await Promise.all([...pendingHydrations])
536 }
537 // Record the tail at the coordinator's ordinary scheduling boundary. Rows
538 // alone cannot distinguish a cached, expired loan from ordinary routing.
539 tailStarted = true
540 commit(() =>
541 source.write({ type: `insert`, value: { id: `tail`, value: 9 } }),
542 )
543 await receiptPromises.at(-1)
544 tailStarted = false
545 const sourceClaimContext = sourceClaimId
546 ? { cacheGenerationClaimId: sourceClaimId }
547 : undefined
548 const sourceTarget = sourceClaimId
549 ? {
550 kind: `managed` as const,
551 storageCollectionId: sourceStorageId,
552 claimId: sourceClaimId,
553 }
554 : { kind: `eager` as const, collectionId: sourceStorageId }
555 const durable = await adapter.loadSubset(
556 sourceTarget,
557 {},
558 sourceClaimContext,
559 )
560 durableRows = durable
561 .map(({ value }) => value as Row)
562 .sort((x, y) => x.id.localeCompare(y.id))
563 durableRowMetadata = durable
564 .filter(({ metadata }) => metadata !== undefined)
565 .map(({ key, metadata }) => ({ key, metadata }))
566 durableMetadata = await adapter.loadCollectionMetadata!(
567 sourceTarget,
568 sourceClaimContext,
569 )
570 peerRows = (
571 await bAdapter.loadSubset({ kind: `eager`, collectionId: `b` }, {})
572 ).map(({ value }) => value as Row)
573 ordinaryRows = (
574 await cAdapter.loadSubset({ kind: `eager`, collectionId: `c` }, {})
575 ).map(({ value }) => value as Row)
576 schemas = [
577 ...(await database.execute<{
578 collection_id: string
579 schema_version: number
580 }>(
581 `SELECT collection_id, schema_version FROM collection_registry ORDER BY collection_id`,
582 )),
583 ]
584 }
585 captured = structuredClone({
586 phase,
587 baseline,
588 rich,
589 browserCoordinator,
590 sourceStorageId,
591 rowReads,
592 cycleCalls,
593 held,
594 receipts: receiptStates,
595 sourceStatus: a.status,
596 peerStatus: b.status,
597 ordinaryReceipt,
598 owningScopeExited,
599 tailScheduling,
600 peerWorkBeforeScopeExit,
601 ordinaryCommitSqlCalls,
602 rows: publicRows(a),
603 durableRows,
604 durableMetadata,
605 durableRowMetadata,
606 peerRows,
607 ordinaryRows,
608 schemas,
609 reopenedRows,
610 errors,
611 })
612 window.__hydrationCommitResult = captured
613 if (cycleCalls === 0) {
614 await a.cleanup()
615 if (phase === `subscription`) {
616 // A partial on-demand cache does not certify offline Collection
617 // restore. A fresh claim still proves the current physical rows were
618 // durably stored after the first sync run releases its claim.
619 const freshClaim = await adapter.claimCacheGeneration!(`a`)
620 try {
621 captured.reopenedRows = (
622 await adapter.loadSubset(
623 {
624 kind: `managed`,
625 storageCollectionId: freshClaim.storageCollectionId,
626 claimId: freshClaim.claimId,
627 },
628 {},
629 {
630 cacheGenerationClaimId: freshClaim.claimId,
631 },
632 )
633 )
634 .map(({ value }) => value as Row)
635 .sort((x, y) => x.id.localeCompare(y.id))
636 } finally {
637 await adapter.releaseCacheGenerationClaim!(freshClaim.claimId)
638 }
639 } else {
640 const reopened = createCollection(
641 persistedCollectionOptions<Row, string>({
642 id: `a`,
643 schemaVersion: 11,
644 persistence,
645 getKey: (row) => row.id,
646 syncMode: `eager`,
647 }),
648 )
649 cleanup.unshift(() => reopened.cleanup())
650 await reopened.preload()
651 captured.reopenedRows = publicRows(reopened)
652 }
653 window.__hydrationCommitResult = structuredClone(captured)
654 }
655 } catch (error) {
656 window.__hydrationCommitError = String(error)
657 } finally {
658 releaseRead.resolve()
659 // A real cycle prevents Collection teardown; closing the worker and the
660 // isolated Playwright page releases it. Other cleanup failures cannot
661 // replace the already-copied primary observation or skip database close.
662 if (params.get(`cleanupFault`) === `true`) {
663 cleanup.unshift(() => {
664 throw new Error(`injected first cleanup failure`)
665 })
666 cleanup.push(() => {
667 throw new Error(`injected last cleanup failure`)
668 })
669 }
670 for (const action of cleanup) {
671 if (cycleCalls > 0) break
672 try {
673 await action()
674 } catch (error) {
675 cleanupErrors.push(String(error))
676 }
677 }
678 try {
679 disposeCoordinator?.()
680 } catch (error) {
681 cleanupErrors.push(String(error))
682 }
683 try {
684 await database.close?.()
685 } catch (error) {
686 cleanupErrors.push(String(error))
687 }
688 window.__hydrationCommitCleanupErrors = cleanupErrors
689 window.__hydrationCommitDone = true
690 }
692void run().catch((error: unknown) => {
693 window.__hydrationCommitError = String(error)
694 window.__hydrationCommitDone = true
695})