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

Firebase Database GET request changes its response when you listen to the parent node's data #12225

Open
russellwheatley opened this issue Dec 28, 2023 · 6 comments
Assignees

Comments

@russellwheatley
Copy link
Member

Description

Firebase Database GET request changes its response when you listen to the parent node's data. It should not change and should always reflect the data on the path of the Firebase Database.

Discovered based on an old issue opened a year ago: firebase/flutterfire#10145

So this is a longstanding bug in the Firebase iOS SDK.

Reproducing the issue

I have created a reproduction repo for you to follow: https://github.com/invertase/database-ios-bug

The instructions are in the README, here they are for clarity:

  1. Add GoogleService-Info.plist to this project.
  2. Update Firebase Database rules to allow read/writes:
{
  "rules": {
    ".read": true,
    ".write": true
  }
}
  1. Run pod install in the root of the project.
  2. Run the app.
  3. Add data to your database by pressing "Write data" button.
  4. Press button "Get "organizations/0/data"" which will retrieve correct data. You will see this in the Xcode console:
Received data: (
    a,
    b,
    c,
    d,
    e,
    f,
    g,
    h
)
  1. Press "Observe "organizations/0"" which will listen to the parent node of step 5 "Get "organizations/0/data"" button press.
  2. Press button "Get "organizations/0/data"" again. Note that the response has changed to:
Received data: {
    city = Lyon;
    country = France;
    data =     (
        a,
        b,
        c,
        d,
        e,
        f,
        g,
        h
    );
    foo = bar;
    id = 0;
    name = "my organization";
}

The response changes after observing the parent nodes data.

Firebase SDK Version

10.19

Xcode Version

15.2

Installation Method

CocoaPods

Firebase Product(s)

Database

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
PODS:
  - Firebase/Core (10.19.0):
    - Firebase/CoreOnly
    - FirebaseAnalytics (~> 10.19.0)
  - Firebase/CoreOnly (10.19.0):
    - FirebaseCore (= 10.19.0)
  - Firebase/Database (10.19.0):
    - Firebase/CoreOnly
    - FirebaseDatabase (~> 10.19.0)
  - FirebaseAnalytics (10.19.0):
    - FirebaseAnalytics/AdIdSupport (= 10.19.0)
    - FirebaseCore (~> 10.0)
    - FirebaseInstallations (~> 10.0)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.11)
    - GoogleUtilities/MethodSwizzler (~> 7.11)
    - GoogleUtilities/Network (~> 7.11)
    - "GoogleUtilities/NSData+zlib (~> 7.11)"
    - nanopb (< 2.30910.0, >= 2.30908.0)
  - FirebaseAnalytics/AdIdSupport (10.19.0):
    - FirebaseCore (~> 10.0)
    - FirebaseInstallations (~> 10.0)
    - GoogleAppMeasurement (= 10.19.0)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.11)
    - GoogleUtilities/MethodSwizzler (~> 7.11)
    - GoogleUtilities/Network (~> 7.11)
    - "GoogleUtilities/NSData+zlib (~> 7.11)"
    - nanopb (< 2.30910.0, >= 2.30908.0)
  - FirebaseAppCheckInterop (10.19.0)
  - FirebaseCore (10.19.0):
    - FirebaseCoreInternal (~> 10.0)
    - GoogleUtilities/Environment (~> 7.12)
    - GoogleUtilities/Logger (~> 7.12)
  - FirebaseCoreInternal (10.19.0):
    - "GoogleUtilities/NSData+zlib (~> 7.8)"
  - FirebaseDatabase (10.19.0):
    - FirebaseAppCheckInterop (~> 10.17)
    - FirebaseCore (~> 10.0)
    - FirebaseSharedSwift (~> 10.0)
    - leveldb-library (~> 1.22)
  - FirebaseInstallations (10.19.0):
    - FirebaseCore (~> 10.0)
    - GoogleUtilities/Environment (~> 7.8)
    - GoogleUtilities/UserDefaults (~> 7.8)
    - PromisesObjC (~> 2.1)
  - FirebaseSharedSwift (10.19.0)
  - GoogleAppMeasurement (10.19.0):
    - GoogleAppMeasurement/AdIdSupport (= 10.19.0)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.11)
    - GoogleUtilities/MethodSwizzler (~> 7.11)
    - GoogleUtilities/Network (~> 7.11)
    - "GoogleUtilities/NSData+zlib (~> 7.11)"
    - nanopb (< 2.30910.0, >= 2.30908.0)
  - GoogleAppMeasurement/AdIdSupport (10.19.0):
    - GoogleAppMeasurement/WithoutAdIdSupport (= 10.19.0)
    - GoogleUtilities/AppDelegateSwizzler (~> 7.11)
    - GoogleUtilities/MethodSwizzler (~> 7.11)
    - GoogleUtilities/Network (~> 7.11)
    - "GoogleUtilities/NSData+zlib (~> 7.11)"
    - nanopb (< 2.30910.0, >= 2.30908.0)
  - GoogleAppMeasurement/WithoutAdIdSupport (10.19.0):
    - GoogleUtilities/AppDelegateSwizzler (~> 7.11)
    - GoogleUtilities/MethodSwizzler (~> 7.11)
    - GoogleUtilities/Network (~> 7.11)
    - "GoogleUtilities/NSData+zlib (~> 7.11)"
    - nanopb (< 2.30910.0, >= 2.30908.0)
  - GoogleUtilities/AppDelegateSwizzler (7.12.0):
    - GoogleUtilities/Environment
    - GoogleUtilities/Logger
    - GoogleUtilities/Network
  - GoogleUtilities/Environment (7.12.0):
    - PromisesObjC (< 3.0, >= 1.2)
  - GoogleUtilities/Logger (7.12.0):
    - GoogleUtilities/Environment
  - GoogleUtilities/MethodSwizzler (7.12.0):
    - GoogleUtilities/Logger
  - GoogleUtilities/Network (7.12.0):
    - GoogleUtilities/Logger
    - "GoogleUtilities/NSData+zlib"
    - GoogleUtilities/Reachability
  - "GoogleUtilities/NSData+zlib (7.12.0)"
  - GoogleUtilities/Reachability (7.12.0):
    - GoogleUtilities/Logger
  - GoogleUtilities/UserDefaults (7.12.0):
    - GoogleUtilities/Logger
  - leveldb-library (1.22.2)
  - nanopb (2.30909.1):
    - nanopb/decode (= 2.30909.1)
    - nanopb/encode (= 2.30909.1)
  - nanopb/decode (2.30909.1)
  - nanopb/encode (2.30909.1)
  - PromisesObjC (2.3.1)

DEPENDENCIES:
  - Firebase/Core
  - Firebase/Database

SPEC REPOS:
  trunk:
    - Firebase
    - FirebaseAnalytics
    - FirebaseAppCheckInterop
    - FirebaseCore
    - FirebaseCoreInternal
    - FirebaseDatabase
    - FirebaseInstallations
    - FirebaseSharedSwift
    - GoogleAppMeasurement
    - GoogleUtilities
    - leveldb-library
    - nanopb
    - PromisesObjC

SPEC CHECKSUMS:
  Firebase: 63ce8ece0d43743dc28eacac0c6867a2d7fd5a9d
  FirebaseAnalytics: 87513010b13b7c8610164d3602ea10571f76afc1
  FirebaseAppCheckInterop: 37884781f3e16a1ba47e7ec80a1e805f987788e3
  FirebaseCore: dc5c7badf99d47613c52b2e3a57a64cd187f8554
  FirebaseCoreInternal: b444828ea7cfd594fca83046b95db98a2be4f290
  FirebaseDatabase: 0bec4d2f36e8d957dac82433f60486c9ec0fc6c1
  FirebaseInstallations: 033d199474164db20c8350736842a94fe717b960
  FirebaseSharedSwift: f34eeb7d3ea87a34497629b6ca41657beadef76a
  GoogleAppMeasurement: 68afe759316673c6554dac35a0c7ae8f5d6cb4ed
  GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34
  leveldb-library: f03246171cce0484482ec291f88b6d563699ee06
  nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
  PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4

PODFILE CHECKSUM: d6f320ad8315dbea36dab2b8e3a93d7d30f8180f

COCOAPODS: 1.14.3

@mortenbekditlevsen
Copy link
Contributor

Hi @russellwheatley ,
I ran into the same issue, and I have a proposal for a fix here:

#12169

@paulb777 paulb777 assigned maneesht and unassigned aashishpatil-g Jan 2, 2024
@mortenbekditlevsen
Copy link
Contributor

@maneesht
May I ask if there's any progress on looking at the PR fmwith a fix for this issue?

@paulb777
Copy link
Member

@mortenbekditlevsen Sorry about the slow progress. After some investigation, the full fix is more challenging than we hoped and we don't have an ETA.

@mortenbekditlevsen
Copy link
Contributor

No worries - I only spotted this one specific issue, so that's all I focused on in the PR.
Happy to hear that the actual fix will apply even more broadly! 😊

@mortenbekditlevsen
Copy link
Contributor

If there's anything I can do to help you out, by the way, please let me know! 😊

@pablosf1
Copy link

pablosf1 commented Apr 3, 2024

Hi all, I'm in the same situation. If you need any information I will be glad to provide it to you. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants