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

Realtime Database - reading data gives wrong value if transaction is pending #2634

Open
terreng opened this issue Jul 16, 2024 · 0 comments
Open

Comments

@terreng
Copy link

terreng commented Jul 16, 2024

[REQUIRED] Step 2: Describe your environment

  • Operating System version: macOS 14.5 (23F79)
  • Firebase SDK version: 12.2.0
  • Firebase Product: database
  • Node.js version: v20.13.0
  • NPM version: v10.5.2

[REQUIRED] Step 3: Describe the problem

If a transaction is pending for a node, it doesn't show up when reading data for the parent node with .once("value", ...). I'm not sure if this is a bug or intended behavior.

Steps to reproduce:

For these examples, our database looks like this:

{
  "example_list": [
    "a",
    "b",
    "c"
  ]
}

This code works as expected:

let ref = admin.database().ref("example_list");

ref.once('value', (snap) => {
    console.log(snap.val())
});

Logs: [ 'a', 'b', 'c' ]

This code does NOT work as expected:

admin.database().ref("example_list/1").transaction((currentData) => {
    return currentData;
});

let ref = admin.database().ref("example_list");

ref.once('value', (snap) => {
    console.log(snap.val())
});

Logs: [ 'a', <1 empty item>, 'c' ]

Adding a transaction first, which seems like a no-op, actually causes the read to return a different result.

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

2 participants