Open
Description
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:
- Add
GoogleService-Info.plist
to this project. - Update Firebase Database rules to allow read/writes:
{
"rules": {
".read": true,
".write": true
}
}
- Run
pod install
in the root of the project. - Run the app.
- Add data to your database by pressing "Write data" button.
- 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
)
- Press "Observe "organizations/0"" which will listen to the parent node of step 5 "Get "organizations/0/data"" button press.
- 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