Skip to content

fix(plugin-nested-docs): await populateBreadcrumbs in resaveChildren hook#16036

Open
KibbeWater wants to merge 2 commits intopayloadcms:mainfrom
KibbeWater:fix/plugin-nested-docs-await-breadcrumbs
Open

fix(plugin-nested-docs): await populateBreadcrumbs in resaveChildren hook#16036
KibbeWater wants to merge 2 commits intopayloadcms:mainfrom
KibbeWater:fix/plugin-nested-docs-await-breadcrumbs

Conversation

@KibbeWater
Copy link
Copy Markdown

What?

Add missing await before populateBreadcrumbs() in the resaveChildren afterChange hook of @payloadcms/plugin-nested-docs.

Why?

populateBreadcrumbs() is an async function, but it was called without await in resaveChildren. This means a Promise object was passed as the data argument to payload.update() instead of the resolved breadcrumb data. In environments with strict transaction isolation, the resulting internal failure can call killTransaction(req) on the shared transaction, silently rolling back the parent document's publish. The catch block only surfaces validation errors, so the rollback goes unnoticed by the user.

In the current codebase, the populateBreadcrumbsBeforeChange hook masks the issue by independently re-fetching parent data during the child update. However, this is an accidental safety net — the resolved data from resaveChildren is still silently discarded and replaced with an unresolved Promise.

How?

  • Added await before populateBreadcrumbs() in packages/plugin-nested-docs/src/hooks/resaveChildren.ts (line 74)
  • Added a unit test that mocks populateBreadcrumbs and asserts payload.update receives the resolved data object, not a Promise — this test fails without the fix
  • Added integration tests covering parent publish stability and child breadcrumb propagation after parent re-publish

@KibbeWater
Copy link
Copy Markdown
Author

@AlessioGr is it possible to get someone looking at this?

@johnSmithTech

This comment was marked as spam.

@AlessioGr AlessioGr self-assigned this Apr 7, 2026
@KibbeWater KibbeWater requested a review from AlessioGr April 7, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants