Deployment error Can't determine Firebase Database URL.
See original GitHub issueVersion info
"firebase-admin": "~6.0.0",
"firebase-functions": "^2.0.5",
> firebase --version
4.2.0
Steps to reproduce
in my package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "./node_modules/.bin/eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"@google-cloud/storage": "^1.7.0",
"@google-cloud/vision": "^0.5.0",
"child-process-promise": "^2.2.0",
"firebase-admin": "~6.0.0",
"firebase-functions": "^2.0.5",
"mkdirp": "^0.5.1",
"mkdirp-promise": "^5.0.1"
},
"devDependencies": {
"eslint": "^5.4.0",
"eslint-plugin-promise": "^4.0.0"
},
"engines": {
"node": "8"
},
"private": true,
"main": "src/index.js"
}
in my index.js
'use strict';
const admin = require('firebase-admin');
admin.initializeApp();
/**
* Storage triggers
*/
const storageTriggers = require('./storageTriggers');
exports.blurOffensiveImages = storageTriggers.blurOffensiveImages;
/**
* Database triggers
*/
const databaseTriggers = require('./databaseTriggers');
exports.sendPhotoCommentNotification = databaseTriggers.sendPhotoCommentNotification;
in my databaseTriggers.js
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const db = admin.database();
...
in my storageTriggers.js which is basically https://github.com/firebase/functions-samples/tree/Node-8/moderate-images
'use strict';
const admin = require('firebase-admin');
const functions = require('firebase-functions');
const mkdirp = require('mkdirp-promise');
const vision = require('@google-cloud/vision')();
const spawn = require('child-process-promise').spawn;
const path = require('path');
const os = require('os');
const fs = require('fs');
...
Were you able to successfully deploy your functions?
Previously yes, but not sure what changed from the previous deploy.
Actual behavior
firebase deploy --only functions
=== Deploying to 'vape-tool'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (74.13 KB) for uploading
✔ functions: functions folder uploaded successfully
i functions: updating Node.js 8 function blurOffensiveImages(us-central1)...
i functions: updating Node.js 8 function sendPhotoCommentNotification(us-central1)...
⚠ functions[blurOffensiveImages(us-central1)]: Deployment error.
Function load error: Code in file src/index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: Error: Can't determine Firebase Database URL.
at FirebaseDatabaseError.FirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:39:28)
at new FirebaseDatabaseError (/srv/node_modules/firebase-admin/lib/utils/error.js:190:23)
at DatabaseService.ensureUrl (/srv/node_modules/firebase-admin/lib/database/database.js:75:15)
at DatabaseService.getDatabase (/srv/node_modules/firebase-admin/lib/database/database.js:52:26)
at FirebaseApp.database (/srv/node_modules/firebase-admin/lib/firebase-app.js:231:24)
at FirebaseNamespace.fn (/srv/node_modules/firebase-admin/lib/firebase-namespace.js:280:45)
at Object.<anonymous> (/srv/src/databaseTriggers.js:20:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
⚠ functions[sendPhotoCommentNotification(us-central1)]: Deployment error.
Function load error: Code in file src/index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: Error: Can't determine Firebase Database URL.
at FirebaseDatabaseError.FirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:39:28)
at new FirebaseDatabaseError (/srv/node_modules/firebase-admin/lib/utils/error.js:190:23)
at DatabaseService.ensureUrl (/srv/node_modules/firebase-admin/lib/database/database.js:75:15)
at DatabaseService.getDatabase (/srv/node_modules/firebase-admin/lib/database/database.js:52:26)
at FirebaseApp.database (/srv/node_modules/firebase-admin/lib/firebase-app.js:231:24)
at FirebaseNamespace.fn (/srv/node_modules/firebase-admin/lib/firebase-namespace.js:280:45)
at Object.<anonymous> (/srv/src/databaseTriggers.js:20:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:35 (10 by maintainers)
Top Results From Across the Web
Can't determine Firebase Database URL - Stack Overflow
I deployed a React app, but I'm receiving the error message: @firebase/database: FIREBASE FATAL ERROR: Can't determine Firebase Database URL. ...
Read more >Can't determine Firebase Database URL - Reddit
I deployed a React app, but I'm receiving the error message: "u/firebase/database: FIREBASE FATAL ERROR: Can't determine Firebase Database ...
Read more >Cloud functions crash with `Error: Can't determine Firebase ...
I faced this issue and after deep research, the problem was from the "firebase-functions" import. This error will happen if you imported firebase-functions ......
Read more >Learn about using and managing API keys for Firebase - Google
An API key is a unique string that's used to route requests to your Firebase project when interacting with Firebase and Google services....
Read more >Firebase Fatal Error: Can't Determine Firebase Database Url
be able to view and manipulate data in your project's Database console. not particularly useful for adding a lot of data or allowing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can confirm that simply requiring
firebase-functions
beforeinitializeApp()
fixes the issue.Looks like in the prod environment it is the
firebase-functions
package that sets the environment variable. So if you initialize Admin SDK before requiring that, your code is going to break.@kevinajian Yes, it fixed the problem.