Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#2,634 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
领域
database

调研方向

从使用 admin.database().ref(...).transaction(...) 的 Node.js 复现开始,随后执行 parent ref.once('value', ...),并比较有无事务时返回的数组。阅读 Realtime Database 的事务和读取行为,以确定预期结果;待事务的情况得到修复,或按照预期得到明确解决,即视为完成。

由索引模型根据 Issue 内容生成。

描述

api: database
[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.

主要语言
TypeScript
星标
1.7k
派生
419
平均合并
4 天 20 小时
30 天内合并 PR
16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-admin-node 的其他 Issue

查看 firebase/firebase-admin-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。