-
Notifications
You must be signed in to change notification settings - Fork 927
Add Emulator Overlay #8977
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
base: main
Are you sure you want to change the base?
Add Emulator Overlay #8977
Conversation
…m/firebase/firebase-js-sdk into mtewani/fix-auth-redirects-studio
🦋 Changeset detectedLatest commit: 1c4c6ee The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
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.
LGTM(firestore)
emitEmulatorWarning(); | ||
} | ||
|
||
// Workaround to get cookies in Firebase Studio | ||
if (isCloudWorkstation(host)) { | ||
void pingServer(`${protocol}//${host}${portStr}`); | ||
updateEmulatorBanner('Auth', true); |
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.
should we honor the disableWarnings flag for this banner? I think the way you have it now there's no way for customer to override it
@@ -393,6 +394,7 @@ export function connectDatabaseEmulator( | |||
// Workaround to get cookies in Firebase Studio | |||
if (isCloudWorkstation(host)) { | |||
void pingServer(host); | |||
updateEmulatorBanner('Database', true); |
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.
ditto here, we need a way to override this
packages/auth/src/api/index.ts
Outdated
@@ -198,7 +199,9 @@ export async function _performFetchWithErrorHandling<V>( | |||
customErrorMap: Partial<ServerErrorMap<ServerError>>, | |||
fetchFn: () => Promise<Response> | |||
): Promise<V> { | |||
(auth as AuthInternal)._canInitEmulator = false; | |||
const authInternal = auth as AuthInternal; | |||
updateEmulatorBanner('Auth', authInternal.emulatorConfig !== null); |
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.
do we need to update this on every call? or just when we do the ping?
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.
What about when the user connects to prod?
if (document.readyState === 'loading') { | ||
window.addEventListener('DOMContentLoaded', setupDom); | ||
} else { | ||
setupDom(); |
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.
will this trigger every time i make an API request? can we cache it somehow?
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.
Not anymore. I refactored to only call updateEmulatorBanner
upon get[Product]
and connect[Product]
.
Here are the flows I tested:
getProduct(); // update banner to prod
connectEmulator(); // update banner to emulator
getProduct(); // No Op because previously the product was connected to the emulator, and you can't un-connect to the emulator.
This adds an overlay to the bottom of the user's screen:
If the user is connected to the emulator, the image will always be shown. If the user is not connected to the emulator, but is on a cloud workstation, then the user will be shown that they are connected to prod.