-
Notifications
You must be signed in to change notification settings - Fork 173
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
Feature: Firebase Emulators support #26
Conversation
Someone is attempting to deploy a commit to a Personal Account owned by @ccrsxx on Vercel. @ccrsxx first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Alright cool, I'll try and review it on Sunday. Thanks hehe. |
I got this error when trying the emulator. I followed the steps readme. It seems that the emulator doesn't run when you run the project with the https://github.com/Goku-kun/twitter-clone/blob/main/package.json#L7. I see that |
Hi! Thanks for getting back. I see. It seems we might need to use another package called I can add it and create a commit. Hang on. |
Hey, @ccrsxx! Can you try again now? |
Yeah, that is correct. Oops, I think I forgot to add that in the README as well. Since I already had it installed, I didn't get this prompt. Edit: You can use this link to install Java JDK of version 11 or higher. |
Okay, thanks. It's almost 200 MB, I'm outside with mobile data right now, will install it when I'm at home. |
@Goku-kun Sorry, couldn't review it right now. I'm pretty busy with work and uni this week. |
Of course, @ccrsxx! No pressure at all. Take your time and do it when you can! All the best with your work and uni though! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the details in the comment. Hmm, it seems my review the other day was not sent to you.
src/lib/context/auth-context.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Goku-kun I just tried it again. I got the emulators working. But right after I logged in with the auth emulator I got this error:
It seems that the request from this line in auth-context
to firestore emulator failed. It returns 401 (Unauthorized) for some reason.
Tried googling myself, but couldn't find the solution lol. Do you have any idea what might've caused it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to take a look at this tomorrow. We're very close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might require some active debugging because it doesn't pinpoint any specific issue. I've sent you a request on Discord. My username is Goku-kun. We can meet for a 30-minute call to discuss this and debug it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested it on your end? and it doesn't work?
I should probably be available on Sunday. I will try to test it on my Mac to see if it's specific to Windows only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested it on Mac and it works. So I tried troubleshooting it on Windows. Turned out the reason why it doesn't work is that the port that the Firebase emulator uses for Firestore is 8080 already used for qBittorent on my PC, that's why.
What a silly oversight by me. Also, the fact that the emulator not showing any error doesn't help lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me do some checking to test if all the features are working, then I'll merge it. Sorry, it took me so long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha. The bug has bitten me differently while running the dev server for NextJS in the project because it's recommended that a port after 1200 be used to run new processes since the earlier ports are reserved for system processes. Port 80 was never unoccupied on Linux. So, I always have to modify the port in the package.json
in this project while developing and revert it before committing the changes.
But, you can actually see in the terminal which emulators are running and which emulators have failed to run. I'm glad we were able to pin it down though. LOL!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good info I don't realize that Linux has that problem, I use both Mac and Windows, neither have that problem. I use port 80 because it looks better for the URL when developing hehe. I might change the port to default in the future so that the linux user doesn't need to manually change the port.
About the PR, I think I could make the steps to run the emulator much shorter by defining the config for the emulator on the project. I'll merge it after I make the change.
@Goku-kun BTW one problem I noticed. So after I run the emulators, when I want to use the Firebase as the server like the usual, not the local emulator it still tries to use the emulators: I see that on the code it still detects and uses the previously running Firebase apps, which is the emulator. Do you know how to fix this so that when you run the project without the emulator, it runs through the server, not the emulator? I'm thinking of using the env variable to decide whether to use the emulator or Firebase server, but this seems a pretty hacky solution. |
The emulators are triggered based on the development environment condition. The If we want to use the production Firebase (not the emulator), then we can build the project using |
Yes, I know that What I mean is that I have a separate Firebase project specifically for the dev environment, not the prod one, and I want to run like the dev server without building it. Is it possible to detect running emulators on dev and then only initialize the Firebase emulator if it's running? I assume many people develop this way (having a Firebase project on the dev) based on this project's Readme, and this change would cause a problem if people try to switch between the emulator and using the Firebase server. |
That is true. I suppose we can create an emulator-only environment variable that triggers the emulators while running the same |
Alright, it seems there's no way to detect emulators besides using the env variable. I will make |
@Goku-kun Damn, what the heck did I do lol. I screwed up the pr, I can't push the above commits because the pr is closed. I don't close it, and I can't reopen it now. Can you push your local repo to your fork repo again, that will hopefully bring this PR back. I was close to merging it lol. |
I make another branch here: https://github.com/ccrsxx/twitter-clone/tree/Goku-kun-main. All the changes are intact from this pr. |
Hmm. I'm not sure if GitHub allows re-opening of PRs the same way it does for issues. Edit: I tried doing what you suggested above. That didn't re-open this PR. Might as well shift to a new PR. |
Hi, @ccrsxx!
Thank you for your patience. This PR resolves #22.
This PR adds support for Firebase local emulators for local development of this Twitter Clone. Additionally, I've also added ample documentation related to the setup of the emulators with images.
One small change that I've add to make is in the src/lib/context/auth-context.tsx file where the clone throws an error in case a profile photo is not provided when using the emulator to login as a new user. This change just adds in a default photorURL for users who don't initially have a photoURL.
Kindly test it out and provide feedback.