Skip to content

Commit d039e43

Browse files
committed
Enable contextual debug logging to help diagnose CI failures
1 parent 61178d5 commit d039e43

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

packages/firestore/src/api/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export function getFirestore(
269269
connectFirestoreEmulator(db, ...emulator);
270270
}
271271
}
272-
272+
273273
return db;
274274
}
275275

packages/firestore/src/local/simple_db.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { getGlobal, getUA, isIndexedDBAvailable } from '@firebase/util';
1919

20-
import { debugAssert } from '../util/assert';
20+
import { debugAssert, fail } from '../util/assert';
2121
import { Code, FirestoreError } from '../util/error';
2222
import { logDebug, logError, logWarn } from '../util/log';
2323
import { Deferred } from '../util/promise';
@@ -355,7 +355,8 @@ export class SimpleDb {
355355
) {
356356
// This thrown error will get passed to the `onerror` callback
357357
// registered above, and will then be propagated correctly.
358-
throw new Error(
358+
fail(
359+
0x3456,
359360
`refusing to open IndexedDB database due to potential ` +
360361
`corruption of the IndexedDB database data; this corruption ` +
361362
`could be caused by clicking the "clear site data" button in ` +

packages/firestore/src/util/log.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,19 @@ const bufferingLogHandler: LogHandler = (instance, logType, ...args): void => {
224224
return;
225225
}
226226

227+
let codeFound = false;
228+
args.forEach(v => {
229+
if (typeof v === 'string' && /ID:\s3456/.test(v)) {
230+
codeFound = true;
231+
}
232+
});
233+
234+
// Buffer any message that do not match the expected code
235+
if (!codeFound) {
236+
logBuffer!.add(logType, now, args);
237+
return;
238+
}
239+
227240
// create identifier that associates all of the associated
228241
// context messages with the log message that caused the
229242
// flush of the logBuffer

packages/firestore/test/integration/util/firebase_export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { PrivateSettings } from '../../../src/lite-api/settings';
3030
let appCount = 0;
3131

3232
// enable contextual debug logging
33-
setLogLevel('error', 100);
33+
setLogLevel('error', 1000);
3434

3535
export function newTestApp(projectId: string, appName?: string): FirebaseApp {
3636
if (appName === undefined) {

0 commit comments

Comments
 (0)