Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .test_patterns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,6 @@ tests:
owners:
- *esau

# boxes
- regex: "BOX=vite BROWSER=webkit run_compose_test vite-webkit box boxes"
error_regex: "WARN: sequencer Too far into slot for INITIALIZING_PROPOSAL"
owners:
- *grego

- regex: "BOX=vanilla BROWSER=webkit run_compose_test vanilla-webkit box boxes"
error_regex: "Test timeout of 90000ms exceeded."
owners:
- *esau

# kind tests
- regex: "spartan/bootstrap.sh"
# Will skip all kind tests for now. Too unstable, blocking merge queue.
Expand Down
15 changes: 11 additions & 4 deletions yarn-project/kv-store/src/indexeddb/store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Logger } from '@aztec/foundation/log';

import { type DBSchema, type IDBPDatabase, deleteDB, openDB } from 'idb';
import { type DBSchema, type IDBPDatabase, type IDBPTransaction, deleteDB, openDB } from 'idb';

import type { AztecAsyncArray } from '../interfaces/array.js';
import type { Key, StoreSize, Value } from '../interfaces/common.js';
Expand Down Expand Up @@ -40,6 +40,7 @@ export interface AztecIDBSchema extends DBSchema {
export class AztecIndexedDBStore implements AztecAsyncKVStore {
#rootDB: IDBPDatabase<AztecIDBSchema>;
#name: string;
#currentTx?: IDBPTransaction<AztecIDBSchema, ['data'], 'readwrite'>;

#containers = new Set<
| IndexedDBAztecArray<any>
Expand Down Expand Up @@ -153,18 +154,24 @@ export class AztecIndexedDBStore implements AztecAsyncKVStore {
* @returns A promise that resolves to the return value of the callback
*/
async transactionAsync<T>(callback: () => Promise<T>): Promise<T> {
const tx = this.#rootDB.transaction('data', 'readwrite');
// We can only have one transaction at a time for the same store
// So we need to wait for the current one to finish
if (this.#currentTx) {
await this.#currentTx.done;
}
this.#currentTx = this.#rootDB.transaction('data', 'readwrite');
for (const container of this.#containers) {
container.db = tx.store;
container.db = this.#currentTx.store;
}
// Avoid awaiting this promise so it doesn't get scheduled in the next microtask
// By then, the tx would be closed
const runningPromise = callback();
// Wait for the transaction to finish
await tx.done;
await this.#currentTx.done;
for (const container of this.#containers) {
container.db = undefined;
}

// Return the result of the callback.
// Tx is guaranteed to already be closed, so the await doesn't hurt anything here
return await runningPromise;
Expand Down