Skip to content

Commit 7645a69

Browse files
authored
Check for missing options / databaseURL on emulator start (#1016)
When using firebase emulators Realtime Database throws an error due to app.options not existing. I've found adding an extra check to the database constructor stops this error, and results in the emulator starting up correctly.
1 parent 4e48f03 commit 7645a69

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
- Parallelizes network calls that occur when validating authorization for onCall handlers.
22
- Adds new regions to V2 API
3+
- Fixes bug where the emulator crashed when given app without an `options` property.

src/providers/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ export class DataSnapshot {
369369
private app?: firebase.app.App,
370370
instance?: string
371371
) {
372-
if (app && app.options.databaseURL.startsWith('http:')) {
372+
if (app?.options?.databaseURL?.startsWith('http:')) {
373373
// In this case we're dealing with an emulator
374374
this.instance = app.options.databaseURL;
375375
} else if (instance) {

0 commit comments

Comments
 (0)