-
Notifications
You must be signed in to change notification settings - Fork 39
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
Non Default Ports Do Not work #11
Comments
@b00t you've run into a lot of bugs and issues trying to use Firebase, so your frustration is 100% warranted. Thank you for continuing to file feedback. The You can either set these yourself, or you can run your tests through I will see if I can improve the error messages in this case so that future users don't get stuck. |
Just to echo @samtstern, this is great feedback; thanks. |
Looks like we already have warnings in the library: Did you see anything in your logs like:
If not, maybe |
@rachelmyers Thanks. @samtstern You are correct in that error appearing. The issue is I couldn't find any documentation on how to set the value. I also asked on other unofficial support channels (e.g. Slack) and searched r/firebase as well as stackoverflow. Given I'm very new to web programming so likely didn't understand the documentation properly. When trying to follow Rachel and Todd's video on unit security rules ( Issue 61 ) eventually I was able to figure out a way to modify the function Todd wrote to change the port being used
This seemed to work for this use case although I still got the error with The issue was that useEmulator does not work for the Admin SDK
As you would get the error: ERROR: TypeError: db.useEmulator is not a function Note, I probably tried things that seem ridiculous to use based on the documentation Attempt 2: Attempt 3: However none of those methods seemed to work. Based on the recent post from sam
It looks like you may actually set the env variables outside of the code in the shell, however I have no idea how to set them or manage them. One last final aside: |
@b0ot thanks for walking us through what you tried. It's really clear that we're making too many assumptions about what you and other web developers understand! We need to be much clearer. Let me explain a bit:
Here's a super quick example of setting and using one:
So if you want to set one for your unit tests, you can just do it when you run the command:
When you run |
Drive-by comment in case anyone want this: If you have to set it within your code in Node.js (which we don't recommend), |
@samtstern thanks for the quick reply and @yuchenshi for the additional information. I was able to get it to run successfully by exporting the env variable in my shell (bash)! I wasn't able to get it to work with I believe there is probably a way I could modify the package.json script files to make it work, but haven't figured it out currently. Eventually I'll make it through this codelab ... after all it says I only have 33 minute remaining :) |
@b0ot we seriously appreciate your patience and this thread has spawned a whole bunch of internal conversation about how we can make this easier and clearer. So your bad experience will at least help the next person! |
We're fixing this issue with two new methods here: Once that is merged and released, we'll update the docs to recommend them. |
I was also very confused about how to set up the environment variable correctly. I just want to share my use case in case it helps anyone. I'm running an app on Nextjs and I'm fetching data on the server using the admin sdk. On Nextjs you set up local environments in a As mentioned here, for permanent setting, you need to understand where to put the “export” script. Where here means Bash Shell Startup Script like /etc/profile, ~/.bash_profile, ~/.bashrc. But frankly I never really understood that part. So in my case, what I ended up doing is:
|
In my package.json I used the following and it works:
|
I know this is a bug report and I shouldn't let my frustrations bleed through, but after spending weeks trying to get a WSL fix only to be forced to downgrade to WSL 1, I was pretty frustrated that I encountered another error so quickly. It has been weeks and countless hours trying to make it through a simple codelab.
Platform: Windows Build 19042.630 w/ WSL Version 1 Ubuntu 20.04
References:
Initially I came across this issue while trying to follow Todd/Rachel's Youtube Video on Unit Security Testing
Issue 61
Description:
I did a clean setup for the emulators code lab and followed the instructions to step 8.
The only change that I had to make is that my default ports are not free, so I had to modify the firebase.json file before running the emulators
During step 8 when I go to run the mocha tests I get the following error:
Based on my experimenting on my referenced issue, I believe that the mocha test doesn't know how to connect to the emulator on non-default ports. I had a work around for initializeTestApp, but could not find a workaround for initializeAdminApp.
The text was updated successfully, but these errors were encountered: