Repository navigation
fix(content-releases): await release cleanup inside its try/catch - #27893
Conversation
The document middlewares and the afterDeleteMany lifecycle wrap the release-action cleanup in try/catch to log failures without blocking the delete or update, but they called the async helpers without await. The catch never ran, so a failure became an unhandled rejection instead of the logged error.
|
This PR has been added to our community triage board as CPR-495. |
|
Keep the locale filter from strapi#28023 and await release-action cleanup so status failures are logged instead of becoming unhandled rejections.
AI-generated QA checklistScope / Impact
Three fire-and-forget calls become awaited, plus one signature change:
Affected: Content Releases (EE-only, gated on Two consequences to watch:
Manual QA
Edge Cases
Test Setup
Possible QA Automation
Assumptions / Gaps
QA ResolutionAdd |
…ails A rejection in the awaited status loop skipped later releases. Catch each refresh, continue, and rethrow the first error so the existing log still runs.
Look up allowed media kinds in a Set, and keep the empty attribute default as a stable reference.
What does it do?
Awaits release-action cleanup and each nested
updateReleaseStatuscall in document delete/update middleware and theafterDeleteManylifecycle. Failures now reach the existing error handlers, while document operations retain their results.Passes the bootstrap Strapi instance into the middleware and cleanup helpers. Regression tests use injected dependencies and typed document contexts instead of
global.strapiorany.Why is it needed?
Calling an async cleanup helper without awaiting it lets its rejection escape the surrounding
try/catch. Awaiting only the outer helper is also insufficient when its release-status updates are not awaited: a failed status query still becomes an unhandled rejection.How to test it?
From
packages/core/content-releases, runyarn jest --runInBand.The 12 cleanup tests exercise the actual middleware and lifecycle registered by bootstrap. They cover lookup, cleanup, and status-update failures on all three paths, plus successful updates of all affected releases. Removing the three nested awaits makes exactly the three status-failure tests fail; restoring them passes all 12.
Validated locally with Node 22.14.0:
draft-releasepassed. That unchanged package failed because Node 22.14.0 did not load.tsfiles directly;NODE_OPTIONS=--experimental-strip-types yarn nx run draft-release:test:unitpassed.Related issue(s)/PR(s)
Fixes CPR-495