Realtime Database - reading data gives wrong value if transaction is pending
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, node.js
- Domain
- database
Research direction
Start with the Node.js reproduction using admin.database().ref(...).transaction(...) followed by a parent ref.once('value', ...), and compare the returned array with and without the transaction. Read the Realtime Database transaction and read behavior to determine the intended result; done means the pending-transaction case is corrected or explicitly resolved as intended.
Written by the indexing model from the issue text.
Description
[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.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 419
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 16
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/firebase-admin-node
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · 3 comments · 1 assignee ·
-
api: messaging
Difficulty 3/5 1-2 days Newbie friendliness 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
Difficulty 5/5 Over a week Newbie friendliness 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 comment · 1 assignee ·
All issues in firebase/firebase-admin-node
Similar issues
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Crush Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
ElementsProject/cln-application#167 · 1 comment · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Quantco/pnpm-licenses#17 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100