Skip to content

Commit 5498749

Browse files
committed
Properly sequence database setups between symbol store tests.
Without this, it's possible that we'll have two database creations triggered right after one another without sequencing. For example, if you have a subtest that creates a SymbolStore but only looks up invalid symbol tables, then the database is never consulted, and nothing will block on the database creation being completed.
1 parent cf15171 commit 5498749

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/profile-logic/symbol-store.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export class SymbolStore {
8585
this._db = new SymbolStoreDB(`${dbNamePrefix}-symbol-tables`);
8686
}
8787

88+
async closeDb() {
89+
await this._db.close();
90+
}
91+
8892
// Store a symbol table in the database. This is only used for symbol tables
8993
// and not for partial symbol results. Symbol tables are generated by the
9094
// geckoProfiler WebExtension API, so these are symbol tables we get from the

src/test/unit/symbol-store.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ describe('SymbolStore', function() {
4040
});
4141

4242
afterEach(async function() {
43+
if (symbolStore) {
44+
await symbolStore.closeDb().catch(() => {});
45+
}
4346
await deleteDatabase();
4447
});
4548

@@ -137,12 +140,10 @@ describe('SymbolStore', function() {
137140
// Using another symbol store simulates a page reload
138141
// Due to https://github.com/dumbmatter/fakeIndexedDB/issues/22 we need to
139142
// take care to sequence the DB open requests.
140-
const symbolStore2 = new SymbolStore(
141-
'perf-html-async-storage',
142-
symbolProvider
143-
);
143+
await symbolStore.closeDb().catch(() => {});
144+
symbolStore = new SymbolStore('perf-html-async-storage', symbolProvider);
144145

145-
await symbolStore2.getSymbols(
146+
await symbolStore.getSymbols(
146147
[{ lib: lib, addresses: new Set([0x1]) }],
147148
(_request, _results) => {},
148149
(_request, _error) => {}

0 commit comments

Comments
 (0)