-
Notifications
You must be signed in to change notification settings - Fork 1k
firebase serve inconsistently adds appId to /__/firebase/init.js #1945
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
Comments
Is it possible you had flaky internet connectivity? We recently made
changes to allow firebase serve to start offline which affect that file (it
used to refuse, now it's best effort) and I wonder if that's causing
trouble.
Doesn't mean it's any less of a bug, just trying to pin it down.
…On Tue, Jan 28, 2020, 7:06 PM Kato Richardson ***@***.***> wrote:
[REQUIRED] Environment info
*firebase-tools:* 7.12.1
*Platform:* macOS and Windows (both on 7.12.1)
[REQUIRED] Test case
Reproducing is inconsistent. However, I encountered this using the Messaging
quickstart
<https://github.com/firebase/quickstart-js/tree/master/messaging#getting-started>
with this index.html file
<https://gist.github.com/katowulf/7089ddd2cd47fdb6fac468fd0f1313d5>.
I can share the demo project if you want to repro locally.
[REQUIRED] Steps to reproduce
git clone https://github.com/firebase/quickstart-js.git
cd quickstart-js/messaging
firebase serve -p 8081
open https://localhost:8081/__/firebase/init.js
Note that the appId is not present.
Try visiting https://localhost:8081 and note the JS errors (quickstart
won't run)
This was reproducible in several projects in different states (with only
one web app, with multiple web apps, old projects and newly created ones,
multiple accounts). It's consistent for any given app, but inconsistent in
which apps work.
Also important to note, the apps DO HAVE an appId when viewed in the
console:
[image: image]
<https://user-images.githubusercontent.com/959972/73324681-0852bb80-4209-11ea-9224-be6ef654c6b9.png>
[REQUIRED] Expected behavior
The init.js file should contain appId.
[REQUIRED] Actual behavior
The init.js file contains something similar to the following:
if (typeof firebase === 'undefined') throw new Error('hosting/init-error: Firebase SDK not detected. You must include it before /__/firebase/init.js');
var firebaseConfig = {
"projectId": "kato-...",
"databaseURL": "https://kato-...io.com",
"storageBucket": "kato-...ot.com",
"locationId": "us-central",
"apiKey": "AIza...ePs",
"authDomain": "kato-...app.com",
"messagingSenderId": "83...95"
};
if (firebaseConfig) {
firebase.initializeApp(firebaseConfig);
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1945?email_source=notifications&email_token=ACATB2V23SR56I5XUFK6FWDRADXCTA5CNFSM4KM53PNKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IJNFZUA>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACATB2SFWIGEDMHLILKRKADRADXCTANCNFSM4KM53PNA>
.
|
Hey @katowulf. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
@kmcnellis showing no mercy throwing the stale bot at @katowulf ! |
In this particular case, it wasn't flaky connectivity, given that it's consistent for a given app/project combination, but inconsistent between multiple apps/projects. Multiple users tried about 10 projects in different states (with only one web app, with multiple web apps, old projects and newly created ones, multiple accounts) but couldn't pin down a pattern. |
I have the same problem, did you all come up with a possible cause on this? |
@Mauratay I think adding the appId into init.js will resolve the issue. Most likely, Sam is correct and it's because the server is not available at the point the project is initialized and the init.js is created. |
Makes sense, wanted to know if it was a problem in particular with the project. Thanks |
We wanted to make the Hosting emulator work offline so we made the helper that fetches the web config for I would guess 9 times out of 10 restarting the emulator fixes it, but if you get it consistently please share debug logs! |
Hi! I’m using the Firebase emulators for 6 months, and I got a strange bug some weeks ago. <script src="/__/firebase/8.0.1/firebase-app.js"></script>
<script src="/__/firebase/8.0.1/firebase-auth.js"></script>
<script src="/__/firebase/8.0.1/firebase-firestore.js"></script>
<script src="/__/firebase/8.0.1/firebase-storage.js"></script>
<script src="/__/firebase/8.0.1/firebase-functions.js"></script>
<script src="/__/firebase/8.0.1/firebase-analytics.js"></script>
<script src="/__/firebase/8.0.1/firebase-performance.js"></script>
<script src="/__/firebase/init.js?useEmulator=true"></script> One day, i got an error message I struggled on this, and go to see if (typeof firebase === 'undefined') throw new Error('hosting/init-error: Firebase SDK not detected. You must include it before /__/firebase/init.js');
var firebaseConfig = {
"projectId": "projectId",
"databaseURL": "databaseURL",
"storageBucket": "storageBucket,
"locationId": "europe-west",
"apiKey": "apiKey",
"authDomain": "authDomain",
"messagingSenderId": "messagingSenderId"
};
if (firebaseConfig) {
firebase.initializeApp(firebaseConfig);
var firebaseEmulators = undefined;
if (firebaseEmulators) {
console.log("Automatically connecting Firebase SDKs to running emulators:");
Object.keys(firebaseEmulators).forEach(function(key) {
console.log('\t' + key + ': http://' + firebaseEmulators[key].host + ':' + firebaseEmulators[key].port );
});
if (firebaseEmulators.database && typeof firebase.database === 'function') {
firebase.database().useEmulator(firebaseEmulators.database.host, firebaseEmulators.database.port);
}
if (firebaseEmulators.firestore && typeof firebase.firestore === 'function') {
firebase.firestore().useEmulator(firebaseEmulators.firestore.host, firebaseEmulators.firestore.port);
}
if (firebaseEmulators.functions && typeof firebase.functions === 'function') {
firebase.functions().useEmulator(firebaseEmulators.functions.host, firebaseEmulators.functions.port);
}
if (firebaseEmulators.auth && typeof firebase.auth === 'function') {
firebase.auth().useEmulator('http://' + firebaseEmulators.auth.host + ':' + firebaseEmulators.auth.port);
}
} else {
console.log("To automatically connect the Firebase SDKs to running emulators, replace '/__/firebase/init.js' with '/__/firebase/init.js?useEmulator=true' in your index.html");
}
} I couldn’t get the |
@ghivert thank you for the clear report! That's actually a new issue, let me open a new one to discuss. |
I'm closing this for now since we've had a lot of CLI updates since then, but please let us know if this is still happening to the latest version |
This issue is 100% still happening and painful |
[REQUIRED] Environment info
firebase-tools: 7.12.1
Platform: macOS and Windows (both on 7.12.1)
[REQUIRED] Test case
Reproducing is inconsistent. However, I encountered this using the Messaging quickstart with this index.html file.
I can share the demo project if you want to repro locally.
[REQUIRED] Steps to reproduce
git clone https://github.com/firebase/quickstart-js.git
cd quickstart-js/messaging
firebase serve -p 8081
open https://localhost:8081/__/firebase/init.js
Note that the appId is not present.
Try visiting https://localhost:8081 and note the JS errors (quickstart won't run)
This was reproducible in several projects in different states (with only one web app, with multiple web apps, old projects and newly created ones, multiple accounts). It's consistent for any given app, but inconsistent in which apps work.
Also important to note, the apps DO HAVE an

appId
when viewed in the console:[REQUIRED] Expected behavior
The
init.js
file should containappId
.[REQUIRED] Actual behavior
The
init.js
file contains something similar to the following:The text was updated successfully, but these errors were encountered: