Skip to content

Fixed automations poll settling#28549

Draft
jonatansberg wants to merge 1 commit into
mainfrom
codex/fix-automations-poll-settling
Draft

Fixed automations poll settling#28549
jonatansberg wants to merge 1 commit into
mainfrom
codex/fix-automations-poll-settling

Conversation

@jonatansberg

@jonatansberg jonatansberg commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

  • updates oneAtATime to return awaitable promises while preserving one-active/one-queued coalescing
  • keeps automations subscribed through oneAtATime so DomainEvents.allSettled() can observe poll completion
  • adds regression coverage for active, queued, coalesced, rejected, and later-queued invocations
  • adds an automations service regression using real DomainEvents.allSettled() tracking

Why

The flaky Members Automations > runs every step in the free member signup automation CI failure came from DomainEvents.allSettled() returning before automation poll handlers had actually finished. The automations service subscribed poll handlers through oneAtATime(), but that wrapper previously returned undefined immediately 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.js
  • CI=true pnpm --dir ghost/core test:single test/unit/server/services/automations/service.test.js
  • DB=sqlite3 NODE_ENV=testing pnpm --dir ghost/core test:single test/e2e-api/members/automations.test.js
  • pnpm --dir ghost/core exec tsc --noEmit --pretty false --skipLibCheck core/shared/one-at-a-time.ts
  • pnpm --dir ghost/core exec eslint --ignore-path .eslintignore core/server/services/automations/service.js core/shared/one-at-a-time.ts
  • pnpm --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

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 517bbe91-c422-4b2c-916f-d77b95ceca44

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-automations-poll-settling

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 12, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 5e6313b

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

@jonatansberg jonatansberg force-pushed the codex/fix-automations-poll-settling branch from ec89603 to e0962eb Compare June 12, 2026 13:10
EvanHahn added a commit that referenced this pull request Jun 12, 2026
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.
@jonatansberg jonatansberg force-pushed the codex/fix-automations-poll-settling branch 2 times, most recently from 1573d95 to 783177e Compare June 12, 2026 14:04
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.
@jonatansberg jonatansberg force-pushed the codex/fix-automations-poll-settling branch from 783177e to 5e6313b Compare June 12, 2026 14:09
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