Skip to content

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

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

fix(plugin-nested-docs): await populateBreadcrumbs in resaveChildren hook#16036
KibbeWater wants to merge 1 commit 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant