Skip to content

Commit 91a6845

Browse files
committed
simple_db.ts: a bit less debug logging
1 parent 4f47f0f commit 91a6845

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

packages/firestore/src/local/indexeddb_schema_converter.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ export class SchemaConverter implements SimpleDbSchemaConverter {
161161

162162
const { idbDatabase: db, debugId: dbDebugId } = idbDatabaseDebugIdPair;
163163

164-
const simpleDbTransaction = new SimpleDbTransaction('createOrUpgrade', txn);
165-
166-
logDebug(`${simpleDbTransaction.debugId} created from ${dbDebugId}`);
164+
const simpleDbTransaction = new SimpleDbTransaction(
165+
'createOrUpgrade',
166+
txn,
167+
dbDebugId
168+
);
167169

168170
if (fromVersion < 1 && toVersion >= 1) {
169171
createPrimaryClientStore(db);

packages/firestore/src/local/simple_db.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface SimpleDbSchemaConverter {
5252
* specific object store.
5353
*/
5454
export class SimpleDbTransaction {
55-
readonly debugId = `SimpleDbTransaction@${generateUniqueDebugId()}`;
55+
readonly debugId: string;
5656
private aborted = false;
5757

5858
/**
@@ -67,21 +67,24 @@ export class SimpleDbTransaction {
6767
objectStoreNames: string[]
6868
): SimpleDbTransaction {
6969
try {
70-
const transaction = new SimpleDbTransaction(
70+
return new SimpleDbTransaction(
7171
action,
72-
db.idbDatabase.transaction(objectStoreNames, mode)
72+
db.idbDatabase.transaction(objectStoreNames, mode),
73+
db.debugId
7374
);
74-
logDebug(`${transaction.debugId} created from ${db.debugId}`);
75-
return transaction;
7675
} catch (e) {
7776
throw new IndexedDbTransactionError(action, e as Error);
7877
}
7978
}
8079

8180
constructor(
8281
private readonly action: string,
83-
private readonly transaction: IDBTransaction
82+
private readonly transaction: IDBTransaction,
83+
readonly dbDebugId: string
8484
) {
85+
this.debugId =
86+
`SimpleDbTransaction@${generateUniqueDebugId()}, ` +
87+
`action="${action}", dbDebugId=${dbDebugId}`;
8588
this.transaction.oncomplete = () => {
8689
this.completionDeferred.resolve();
8790
};
@@ -148,9 +151,7 @@ export class SimpleDbTransaction {
148151
): SimpleDbStore<KeyType, ValueType> {
149152
const store = this.transaction.objectStore(storeName);
150153
debugAssert(!!store, 'Object store not part of transaction: ' + storeName);
151-
const simpleDbStore = new SimpleDbStore<KeyType, ValueType>(store);
152-
logDebug(`${simpleDbStore.debugId} created from ${this.debugId}`);
153-
return simpleDbStore;
154+
return new SimpleDbStore<KeyType, ValueType>(store, this.debugId);
154155
}
155156
}
156157

@@ -755,9 +756,11 @@ export class SimpleDbStore<
755756
KeyType extends IDBValidKey,
756757
ValueType extends unknown
757758
> {
758-
readonly debugId = `SimpleDbStore@${generateUniqueDebugId()}`;
759+
readonly debugId: string;
759760

760-
constructor(private store: IDBObjectStore) {}
761+
constructor(private store: IDBObjectStore, transactionId: string) {
762+
this.debugId = transactionId;
763+
}
761764

762765
/**
763766
* Writes a value into the Object Store.

0 commit comments

Comments
 (0)