Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'FIREBASE_DATABASE_EMULATOR_HOST') #5789

Closed
nandenjin opened this issue Dec 5, 2021 · 1 comment · Fixed by #5790

Comments

@nandenjin
Copy link
Contributor

nandenjin commented Dec 5, 2021

[REQUIRED] Describe your environment

  • Operating System version: Windows 10 Home 21H1
  • Browser version: Chrome 96.0.4664.45
  • Firebase SDK version: 9.6.0
  • Firebase Product: database

[REQUIRED] Describe the problem

Typecheck of process.env in firebase/database is insufficient. In some cases global variable process can be with no process.env. I have some TypeErrors from browser-based runtime:

image

f/packages/database/src/api/Database.ts reads process.env.FIREBASE_DATABASE_EMULATOR_HOST with undefined check for process but not for process.env.

if (typeof process !== 'undefined') {
dbEmulatorHost = process.env[FIREBASE_DATABASE_EMULATOR_HOST_VAR];
}

Steps to reproduce:

👀 See also: codesandbox

I found the problem with Nuxt.js (nuxt3 3.0.0-27306170.bd36e13). It should be reproduced with [email protected] and following code.

Relevant Code:

/*
// Actually it can be reproduce without Nuxt but with:
process.env = null
*/

import { initializeApp, getApps } from "firebase/app";
import { getDatabase } from "firebase/database";

initializeApp({
  databaseURL: "https://sample.firebase.io",
});
const db = getDatabase();
@manjurulislamkhan
Copy link

Similar problem with Firebase Storage. Cannot read path at undefined when using ref(storage, url)

Works with firebase 9.0.0.

@firebase firebase locked and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants