Skip to content
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

Emulator Idempotency: Database #8769

Merged
merged 16 commits into from
Feb 11, 2025
Merged

Conversation

DellaBitta
Copy link
Contributor

@DellaBitta DellaBitta commented Feb 6, 2025

Discussion

Update the connectDatabaseEmulator function to support its invocation more than once. If the Database instance is already in use, and connectDatabaseEmulator is invoked with the same configuration, then the invocation will now succeed instead of assert.

This unlocks support for web frameworks which may render the page numerous times with the same instances of RTDB. Before this PR customers needed to add extra code to guard against calling connectDatabaseEmulator in their SSR logic. Now we do that guarding logic on their behalf which should simplify our customer's apps.

Fixes #6824.

Testing

CI, new tests added to integration tests.

API Changes

N/A

Copy link

changeset-bot bot commented Feb 6, 2025

🦋 Changeset detected

Latest commit: 7bfbec9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/database-compat Patch
@firebase/database Patch
firebase Patch

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

Copy link
Contributor

github-actions bot commented Feb 6, 2025

Vertex AI Mock Responses Check ⚠️

A newer major version of the mock responses for Vertex AI unit tests is available. update_vertexai_responses.sh should be updated to clone the latest version of the responses: v6.1

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Feb 6, 2025

Size Report 1

Affected Products

  • @firebase/app

    TypeBase (5250e80)Merge (2278ffa)Diff
    browser19.5 kB19.5 kB-1 B (-0.0%)
    main20.4 kB20.4 kB-1 B (-0.0%)
    module19.5 kB19.5 kB-1 B (-0.0%)
  • @firebase/database

    TypeBase (5250e80)Merge (2278ffa)Diff
    browser249 kB249 kB+300 B (+0.1%)
    main254 kB254 kB+295 B (+0.1%)
    module249 kB249 kB+300 B (+0.1%)
  • @firebase/database-compat/standalone

    TypeBase (5250e80)Merge (2278ffa)Diff
    main366 kB366 kB+294 B (+0.1%)
  • @firebase/performance

    TypeBase (5250e80)Merge (2278ffa)Diff
    browser30.6 kB30.6 kB-1 B (-0.0%)
    main31.1 kB31.1 kB-1 B (-0.0%)
    module30.6 kB30.6 kB-1 B (-0.0%)
  • bundle

    46 size changes

    TypeBase (5250e80)Merge (2278ffa)Diff
    analytics (logEvent)44.7 kB44.7 kB-1 B (-0.0%)
    app-check (CustomProvider)37.4 kB37.4 kB-1 B (-0.0%)
    app-check (ReCaptchaEnterpriseProvider)39.9 kB39.9 kB-1 B (-0.0%)
    app-check (ReCaptchaV3Provider)39.9 kB39.9 kB-1 B (-0.0%)
    auth (Anonymous)76.6 kB76.6 kB-1 B (-0.0%)
    auth (EmailAndPassword)86.8 kB86.8 kB-1 B (-0.0%)
    auth (GoogleFBTwitterGitHubPopup)104 kB104 kB-1 B (-0.0%)
    auth (GooglePopup)101 kB101 kB-1 B (-0.0%)
    auth (GoogleRedirect)101 kB101 kB-1 B (-0.0%)
    auth (Phone)94.2 kB94.2 kB-1 B (-0.0%)
    database (Append to a list of data)150 kB150 kB+171 B (+0.1%)
    database (Filtering data)148 kB149 kB+171 B (+0.1%)
    database (Listen for child events)165 kB165 kB+171 B (+0.1%)
    database (Listen for value events + Detach listeners)165 kB165 kB+171 B (+0.1%)
    database (Listen for value events)165 kB165 kB+171 B (+0.1%)
    database (Read data once)164 kB164 kB+171 B (+0.1%)
    database (Save data as transactions)167 kB167 kB+171 B (+0.1%)
    database (Sort data)150 kB150 kB+171 B (+0.1%)
    database (Write data)149 kB149 kB+171 B (+0.1%)
    firestore (CSI Auto Indexing Disable and Delete)271 kB271 kB-1 B (-0.0%)
    firestore (CSI Auto Indexing Enable)271 kB271 kB-1 B (-0.0%)
    firestore (Persistence)303 kB303 kB-1 B (-0.0%)
    firestore (Query Cursors)250 kB250 kB-1 B (-0.0%)
    firestore (Query)247 kB247 kB-1 B (-0.0%)
    firestore (Read data once)235 kB235 kB-1 B (-0.0%)
    firestore (Read Write w Persistence)327 kB327 kB-1 B (-0.0%)
    firestore (Realtime updates)237 kB237 kB-1 B (-0.0%)
    firestore (Transaction)214 kB214 kB-1 B (-0.0%)
    firestore (Write data)214 kB214 kB-1 B (-0.0%)
    firestore-lite (Query Cursors)103 kB103 kB-1 B (-0.0%)
    firestore-lite (Query)99.4 kB99.4 kB-1 B (-0.0%)
    firestore-lite (Read data once)74.8 kB74.8 kB-1 B (-0.0%)
    firestore-lite (Transaction)100 kB100 kB-1 B (-0.0%)
    firestore-lite (Write data)84.4 kB84.4 kB-1 B (-0.0%)
    functions (call)34.8 kB34.8 kB-1 B (-0.0%)
    messaging (send + receive)47.5 kB47.5 kB-1 B (-0.0%)
    performance (trace)62.4 kB62.4 kB-2 B (-0.0%)
    remote-config (getAndFetch)47.7 kB47.7 kB-1 B (-0.0%)
    storage (getBytes)42.4 kB42.4 kB-1 B (-0.0%)
    storage (getDownloadURL)44.5 kB44.5 kB-1 B (-0.0%)
    storage (getMetadata)43.9 kB43.9 kB-1 B (-0.0%)
    storage (list + listAll)43.3 kB43.3 kB-1 B (-0.0%)
    storage (updateMetadata)44.2 kB44.2 kB-1 B (-0.0%)
    storage (uploadBytes)49.0 kB49.0 kB-1 B (-0.0%)
    storage (uploadBytesResumable)59.0 kB59.0 kB-1 B (-0.0%)
    storage (uploadString)49.3 kB49.3 kB-1 B (-0.0%)

  • firebase

    TypeBase (5250e80)Merge (2278ffa)Diff
    firebase-app-compat.js31.8 kB31.8 kB-1 B (-0.0%)
    firebase-app.js103 kB103 kB-1 B (-0.0%)
    firebase-compat.js791 kB791 kB+167 B (+0.0%)
    firebase-database-compat.js164 kB164 kB+442 B (+0.3%)
    firebase-database.js187 kB187 kB+513 B (+0.3%)
    firebase-performance-compat.js40.0 kB40.0 kB-1 B (-0.0%)
    firebase-performance-standalone-compat.js105 kB105 kB-2 B (-0.0%)
    firebase-performance.js45.5 kB45.5 kB-1 B (-0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/isx7qBYUMf.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Feb 6, 2025

Size Analysis Report 1

This report is too large (172,033 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/tQLiotO8LH.html

@DellaBitta DellaBitta changed the title Debug Database Idempotency - Do not merge Debug Database Idempotency Feb 6, 2025
@DellaBitta DellaBitta changed the title Debug Database Idempotency Emulator Idempotency: Database Feb 7, 2025
@DellaBitta DellaBitta marked this pull request as ready for review February 7, 2025 14:45
@DellaBitta DellaBitta requested a review from dlarocque February 7, 2025 15:01
@@ -138,6 +141,43 @@ describe('Database@exp Tests', () => {
unsubscribe();
});

it('can connected to emulator', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: some typos. "can connected to" here and in 160, "chnage" in 151

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

packages/database/test/exp/integration.test.ts Outdated Show resolved Hide resolved
packages/database/src/core/RepoInfo.ts Show resolved Hide resolved
@DellaBitta DellaBitta merged commit b3e68ca into main Feb 11, 2025
38 checks passed
@DellaBitta DellaBitta deleted the ddb-database-emulator-reconnect-2 branch February 11, 2025 21:48
@DellaBitta DellaBitta restored the ddb-database-emulator-reconnect-2 branch February 11, 2025 21:48
@DellaBitta DellaBitta deleted the ddb-database-emulator-reconnect-2 branch February 11, 2025 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

two attempts to connect to auth emulator cause config error
5 participants