Skip to content

Commit 191184e

Browse files
authored
Prevent v8 database trying to register with v9 app. (#4801)
* Prevent v8 database trying to register with v9 app. * Create tall-bikes-own.md
1 parent c658836 commit 191184e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/tall-bikes-own.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/database": patch
3+
---
4+
5+
Fixes an internal conflict when using v8 and v9 SDKs in the same package.

packages/database/index.node.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ try {
123123
// @firebase/app when used together with the js sdk. More detail:
124124
// https://github.com/firebase/firebase-js-sdk/issues/1696#issuecomment-501546596
125125
// eslint-disable-next-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports
126-
const firebase = require('@firebase/app').default;
127-
registerDatabase(firebase);
126+
const firebase = require('@firebase/app').default; // Only present for v8, undefined for v9 (should skip).
127+
if (firebase) {
128+
registerDatabase(firebase);
129+
}
128130
} catch (err) {
129131
// catch and ignore 'MODULE_NOT_FOUND' error in firebase-admin context
130132
// we can safely ignore this error because RTDB in firebase-admin works without @firebase/app

0 commit comments

Comments
 (0)