How to hide java console when running "firebase emulators:start"? - firebase

After I run the command firebase emulators:start, the java console pops up:
How can I run the firebase emulators without showing the console?
Is there a way to run the console in hidden mode?

There's an open bug here, right now there's no flag provided by Firebase to avoid the popup:
https://github.com/firebase/firebase-tools/issues/3506

Related

Firebase emulator prevent log window from opening

When I run the firebase emulators:start command on Windows 10, it opens up a console with what looks like a java program outputting log events from the emulator suite. Is there any way to prevent this window from opening?
Thanks!
edit: This window doesn't even close after emulators:exec finishes its command, preventing a proper cleanup.
First of all , this link can help you on how to shutdown correctly the JVMs:
Shut down JVM when Firebase emulator closes
Since you're talking about Java console , then you should use javaw.exe instead of java.exe ! Javaw prevents logs from appearing in console . I'm not an expert of firebase but I believe there's a config file in which there's a call to Java binary which launches the JVM and finally change the java by javaw

Firebase functions emulator does not watch for changes

Environment info
firebase --version --> 11.1.0
node -v --> v16.15.1
npm -v --> 8.11.0
Platform:
Pop!_OS 22.04 LTS 64-bit
Steps to reproduce
1). run firebase init functions
2). Select Use an existing project and choose my project.
3). Select Javascript for the language.
4). Type N and press enter to not use eslint.
5). Type Y and press enter to install dependencies.
6). run firebase emulators:start or firebase emulators:start --only functions
7). Open functions/index.js and uncomment the helloWorld example, and save.
Expected behavior
I expect the functions emulator to detect the changes to the javascript code and to automatically apply those changes without restarting the emulator (manually).
Actual behavior
Nothing changes. I have to restart the emulator to use the helloWorld function. Or if the function was there when the emulator was started I have to restart it to see changes made to the function itself. If I make changes to the firestore.rules file while running the firestore emulator those changes are registered without restarting the emulator(s) like it's supposed to.
If you're using "native" Node.js, any changes/modification in the code after running the emulator will not be reflected. By using different Javascript library, you can transpile/compile your code as watch mode before running Firebase emulator to see the changes upon modification of the code. You can also refer to this documentation:
Code changes you make during an active session are automatically
reloaded by the emulator. If your code needs to be transpiled
(TypeScript, React) make sure to do so before running the emulator.
You can run your transpiler in watch mode with commands like tsc -w to
transpile and reload code automatically as you save.

Shut down JVM when Firebase emulator closes

firebase-tools is an NPM package that uses the JVM. It includes an emulators:start command which fires up the JVM, and it has the JVM use some ports (defined in settings) for the emulators' input/output.
I use MacOS. I use a VSCode terminal to start/end the emulators, and define the details of how to start using an NPM script. Like this:
npm run build && firebase emulators:start --only functions,auth,firestore,database --import ./db-temp
In other words, run the build script, then start some emulator services.
So when running the emulators, I:
Open a terminal,
Navigate to the folder containing the script
Run the script (npm run serve)
This gives me a convenient place to get feedback from the emulators for things like errors, network activity, etc.
If I close VSCode using VSCode's X button, everything in VSCode is immediately shut down. When the terminal is closed, the JVM doesn't detect this and quit: it keeps running. Then when I open VSCode and try running my script again, it tells me that the port normally used by the emulators is still open, because the JVM didn't shut down properly. So I have to track down the JVM process, Force Quit it, and then everything works fine.
To shut the emulators down properly, I have to go to the terminal process running the emulators, press ALT+C to close the process, and then close VSCode. This extra step is inconvenient, and easily forgotten.
Can I convince the JVM to shut down when its originating process terminates via a configuration option? I looked through the configuration options on my local machine via java and java -x, and didn't see anything promising, but I am sure that there are people who know much more about Java than I do.
The Firebase emulator has an environment variable available for Java configuration.
I would be open to other options if available: telling VSCode to automatically shut down terminals properly before exiting, for example.
Or must this be handled by firebase-tools itself, perhaps via a ShutdownHook?
After a little conversation with Firebase and some troubleshooting, I learned a few things:
This issue only occurs when running firebase emulators:start --only firestore,database: when they run together, the Firestore process never closes. Start either one by itself and everything closes fine. This leads me to suspect that this is a bug.
This is reproducible outside VSCode, leading me to suspect that the issue has nothing to do with VSCode.
I filed https://github.com/firebase/firebase-tools/issues/4657. We'll see how it turns out.

Problem with Firebase in SwiftUI macos app. [Running InstanceID on a simulator doesn't have APNS. Use prod profile by default.]

I wanted to run my swiftui app on macos, unfortunately i can still see error That
Running InstanceID on a simulator doesn't have APNS. Use prod
profile by default.
I used the code from firebase messaging docs to initialize firebase messaging and later on I wanted to get instance id token.
While using Xcode I don't get any other errors instead of this which I mentioned. That's why I decided to archive my app and run it independently
outside Xcode. Unfortunately I still can see in console error message about running in simulator. When I run that code on my physical iPhone everything works properly.
Xcode log
Mac console log
Does anyone know what should I change or how should I archive the app properly in order to firebase not detect my app as simulator?

Cannot login with the Firebase CLI

I have a problem when I try to login to Firebase using the CLI. I installed firebase-tools using npm -g install firebase-tools with admin rights. The steps I do are (from a cygwin terminal on Windows 10 Professional):
firebase login --no-localhost
After this I get the message:
Visit the URL on any device....
Paste authentication code here:
Then, on my browser, I see Google asking if I give Firebase CLI access rights, I say yes and then I get an authorization code displayed on the browser.
I copy this code into the cygwin console and then:
Error: Authentication Error.
I'm at a total loss for this and it's completely stalling my efforts to get to know Firebase. All help gratefully appreciated.
Try:
firebase login --interactive
it will open up a browser window to authenticate.
In my case was bug in terminal in Visual Studio Code. On CMD terminal it start works.
On windows 10, I had issues with my firebase login through cli. I had to run my command line as the administrator and it worked.
I got the same issue today and it was because back in the day I used firebase and didn't remove this define from my bash_profile
FIREBASE_TOKEN
try echo $FIREBASE_TOKEN if something shows up try deleting, open new terminal and re-authenticating
This works for me.
my FIREBASE_TOKEN was FIREBASE_TOKEN=' '. I logged out of all my terminal sessions and tried again and that worked.
Just run the cmd wit administrator privilege...! Happy coding
If you really can't log in with firebase CLI using the "firebase login" command
Then, use GitBash instead of PowerShell in the VS code or any other code editor terminal.
First, download Git SCM then use gitbash in the terminal for any kind of Firebase hosting command terminal image using gitBash
It does work actually!!
I used with cmd, it was worked.
I copy pasted the link into an incognito window, and somehow it worked.
After running across this problem I tried multiple different things to solve this:
Used firebase login --reauth
Used firebase login --no-localhost
Turned off proxy settings
Ran command from within windows/system32
Turned off my security settings in Firefox
All these options listed above worked for others but not for me
Finally the way it worked was to install google chrome and run the command from from chrome instead of firefox
Check your firebase version. if firebase version is "8.15.0" this, then its okay, if not: uninstall firebase-tools globally and globally install it again with 'version'
npm i --global firebase-tools#8.15.0
then after check which terminal u r using, make sure to use cmd terminal. go to your directory and fire command
firebase login.
Check if its working

Resources