Skip to content

🐛 Fixed flaky target delivery window batch-sending test#28937

Open
9larsons wants to merge 1 commit into
mainfrom
fix-batch-sending-delivery-window-flake
Open

🐛 Fixed flaky target delivery window batch-sending test#28937
9larsons wants to merge 1 commit into
mainfrom
fix-batch-sending-delivery-window-flake

Conversation

@9larsons

Copy link
Copy Markdown
Contributor

The Target Delivery Window > can send an email with a target delivery window set integration test asserts that every batch is sent with an o:deliverytime option. This fails intermittently (seen on the mysql8 acceptance leg) with Expected: "string" / Received: "undefined".

The first/immediate batch's delivery time is computed as "now" (delay 0). The sender intentionally drops any delivery time that is no longer in the future (deliveryTime >= Date.now() in batch-sending-service.js) — it never schedules a delivery in the past — so once a millisecond elapses between calculation and dispatch, the first batch correctly sends with no delivery time. The test then fails. On a same-millisecond run all four batches keep their time and it passes, which is why it's flaky, and more so under the slower/jittery mysql8 leg.

This asserts the windowed batches each carry a valid o:deliverytime within the deadline (and tolerates the immediate batch having none, without assuming worker/batch ordering), rather than requiring a delivery time on every batch.

Verified locally on sqlite: passes across repeated runs.

The test asserted every batch carried an o:deliverytime, but the first/
immediate batch's delivery time is "now" at calculation time, which the
sender drops once the clock ticks past it (it never schedules delivery in
the past). When a millisecond elapsed between calculation and dispatch the
first batch sent with no deliverytime, failing the assertion intermittently
(more often on the slower mysql8 CI leg).

Assert the windowed batches each carry a valid deliverytime within the
deadline instead of requiring one on every batch.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 211b1271-3657-453c-882c-3eef10d28cca

📥 Commits

Reviewing files that changed from the base of the PR and between 0ed0d9f and 2ffb17a.

📒 Files selected for processing (1)
  • ghost/core/test/integration/services/email-service/batch-sending.test.js

Walkthrough

The target delivery window test now collects all stubbedSend delivery times, filters to string-valued scheduled deliveries, requires at least three scheduled batches, and checks each scheduled timestamp is on or before the computed deadline.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the flaky target delivery window batch-sending test fix.
Description check ✅ Passed The description directly explains the flaky test behavior and the fix applied, matching the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-batch-sending-delivery-window-flake

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.

@nx-cloud

nx-cloud Bot commented Jun 26, 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 2ffb17a

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 35s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 41s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 48s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 27s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 30s View ↗
nx run-many -t lint -p ghost ✅ Succeeded 33s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-26 19:11:02 UTC

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.

2 participants