v4: a failing local API operation rolls back a transaction the caller owns, so later writes commit outside it
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- node.js, postgresql, typescript
調査の方向性
Start with the catch blocks in packages/payload/src/collections/operations/create.ts, then compare the listed catch blocks in update.ts, updateByID.ts, delete.ts, deleteByID.ts, restoreVersion.ts and renameFile.ts. Trace how initTransaction signals whether an operation owns the transaction and how killTransaction uses that ownership. Reproduce with repro-2.ts; done when a failed operation leaves the caller's transaction intact and the writes behave as expected at commit.
索引モデルが issue の本文から書いたものです。
説明
Describe the Bug
When the caller owns a transaction (it called payload.db.beginTransaction() and passes req.transactionID), a local-API create that fails (here a validation error) rolls back the caller's transaction and deletes req.transactionID. The operation's catch calls killTransaction(args.req) unconditionally (packages/payload/src/collections/operations/create.ts), even though initTransaction returned false for it because the transaction was not its own. killTransaction's own doc comment says only the operation that started the transaction should call it.
For a caller that catches the error and carries on (e.g. a bulk import that skips invalid rows), the result is:
- the writes made before the failure are silently rolled back;
req.transactionIDis nowundefined, so the writes made after it run outside any transaction and commit on their own;- the caller's
commitTransactionhas nothing to commit, so no error is raised anywhere.
Expected: an operation that did not start the transaction leaves it alone (the caller decides whether to roll back), or at least the caller's commit fails loudly.
update.ts, updateByID.ts, delete.ts, deleteByID.ts, restoreVersion.ts and renameFile.ts have the same unconditional killTransaction in their catch.
Link to the code that reproduces this issue
https://github.com/elghaied/payload-v4-reproductions (repro-2.ts)
Reproduction Steps
pnpm install, thencp .env.example .envand pointDATABASE_URLat an empty PostgreSQL databasepnpm repro repro-2.ts
The script begins a transaction, creates note A, tries to create an invalid note (the error is caught), creates note C, then commits. Output:
transactionID before failing op: 7833329b-0871-4092-aa20-c1ef0a475cfa
expected failure: The following field is invalid: Title
transactionID after failing op: undefined (caller owns it; should be unchanged)
observed committed: [ 'tx-…-C' ] expected: [A, C] together (or loud commit failure)
Which area(s) are affected?
area: core, db-postgres
Environment Info
payload: 4.0.0-beta.9
@payloadcms/db-postgres: 4.0.0-beta.9
Node.js: 24.22.1
PostgreSQL: 17.10
(local API only, no Next.js app)
- 主要言語
- TypeScript
- スター
- 45.8k
- フォーク
- 4.4k
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 210
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
payloadcms/payload のほかの issue
-
area: ui Bug Payload OSS
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
payloadcms/payload#19839 ·
メンテナーはふだん 1 日以内に返信
-
Accessibility: list row and select-all checkboxes still unnamed in 3.x (#17376 fix not in 3.91)オープンBug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
payloadcms/payload#19837 ·
メンテナーはふだん 1 日以内に返信
-
Bug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
payloadcms/payload#19835 ·
メンテナーはふだん 1 日以内に返信
-
Bug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
payloadcms/payload#19833 ·
メンテナーはふだん 1 日以内に返信
-
Bug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
payloadcms/payload#19832 ·
メンテナーはふだん 1 日以内に返信
payloadcms/payload の issue をすべて見る
似ている issue
-
[BUG]: Shared links drop the configured basePath on GitHub Pages対応中かも @anshulchikhale30-p が今日担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Add: GTrekkerオープンcheck:passed streams:add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
メンテナーはふだん 1 日以内に返信