Fixed automations poll settling#28549
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration:no-coverage |
✅ Succeeded | 1m 55s | View ↗ |
nx run ghost:test:ci:e2e:no-coverage |
✅ Succeeded | 10m 16s | View ↗ |
nx run ghost:test:ci:integration |
✅ Succeeded | 1m 7s | View ↗ |
nx run ghost:test:ci:e2e |
✅ Succeeded | 3m 46s | View ↗ |
nx run ghost:test:ci:legacy |
✅ Succeeded | 3m 32s | View ↗ |
nx build @tryghost/comments-ui |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/activitypub |
✅ Succeeded | 3s | View ↗ |
nx build @tryghost/signup-form |
✅ Succeeded | <1s | View ↗ |
Additional runs (10) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-12 14:25:34 UTC
ec89603 to
e0962eb
Compare
towards https://linear.app/ghost/issue/NY-1341 ref https://github.com/TryGhost/Ghost/actions/runs/27403034105/ ref #28549 This is a quick fix to make an automations test more reliable. We plan to make a proper fix in the future.
1573d95 to
783177e
Compare
no ref DomainEvents.allSettled() is used by the automations tests after scheduler polls, but oneAtATime returned before async poll work settled. Returning awaitable promises from oneAtATime keeps the existing one-active/one-queued coalescing behaviour while making the event handler completion observable.
783177e to
5e6313b
Compare

Summary
oneAtATimeto return awaitable promises while preserving one-active/one-queued coalescingoneAtATimesoDomainEvents.allSettled()can observe poll completionDomainEvents.allSettled()trackingWhy
The flaky
Members Automations > runs every step in the free member signup automationCI failure came fromDomainEvents.allSettled()returning before automation poll handlers had actually finished. The automations service subscribed poll handlers throughoneAtATime(), but that wrapper previously returnedundefinedimmediately after starting async work, so the domain event dispatcher had nothing to await when polls queued follow-up work under CI load.This keeps the existing helper as the single coalescing implementation and makes its completion contract explicit.
Review
A separate sub-agent did a grumpy senior-dev review focused on async race conditions, promise ownership, queue/coalescing semantics, and test quality. Its findings were addressed, then re-reviewed with no remaining findings.
Verification
CI=true pnpm --dir ghost/core test:single test/unit/shared/one-at-a-time.test.jsCI=true pnpm --dir ghost/core test:single test/unit/server/services/automations/service.test.jsDB=sqlite3 NODE_ENV=testing pnpm --dir ghost/core test:single test/e2e-api/members/automations.test.jspnpm --dir ghost/core exec tsc --noEmit --pretty false --skipLibCheck core/shared/one-at-a-time.tspnpm --dir ghost/core exec eslint --ignore-path .eslintignore core/server/services/automations/service.js core/shared/one-at-a-time.tspnpm --dir ghost/core exec eslint -c test/.eslintrc.js --ignore-path test/.eslintignore test/unit/server/services/automations/service.test.js test/unit/shared/one-at-a-time.test.js