GeezerVison is showing github.com — perf(relay): iOS alerts stop waiting up to 5 s for an APNs batch to fill (1 s, like FCM) by Pyseph · Pull Request #31034 · pingdotgg/t3code
Conversation
Problem
Every APNs delivery, meaning iOS alerts and Live Activity updates, goes through the apnsDeliveryQueue consumer in infra/relay/src/worker.ts. That consumer is configured with batchSize: 10, maxWaitTime: "5 seconds". A Cloudflare Queues consumer receives a batch when it is full or when the batch timeout passes. So whenever fewer than 10 deliveries are waiting, the first one sits in the queue for the full 5 s before the consumer runs.
Those values are Cloudflare's defaults (max_batch_size 10, max_batch_timeout 5 s), and #2837, which added the APNs service, doesn't discuss them. The FCM consumer added in #10416 uses maxWaitTime: "1 second". An Android alert therefore waits at most about 1 s in the queue, and an iOS alert up to 5 s.
Measured locally with miniflare 4.20260730.0, the runtime alchemy's local provider uses, with the same consumer settings (time from send to the consumer's queue() start):
| Case |
5 s timeout (today) |
1 s timeout (this PR) |
| Lone message, n=20 |
5,007.5 ms median (min 5,002) |
1,010.5 ms median (min 1,003) |
| Burst of 3 |
5,013 ms |
1,010 ms |
| Burst of 10 (full batch) |
2 ms |
2 ms |
This simulates Cloudflare's documented semantics; it isn't production latency. Under high global traffic batches fill sooner. With messages arriving at a steady λ per second, the first message in a batch waits about min(T, 9/λ):
| Traffic |
Today (T = 5 s) |
This PR (T = 1 s) |
| 1 per second |
5 s |
1 s |
| 2 per second |
4.5 s |
1 s |
| 10 per second |
0.9 s |
0.9 s |
Change
The APNs consumer's maxWaitTime changes from "5 seconds" to "1 second", the FCM value. Nothing else changes. Alchemy passes the setting through as maxWaitTimeMs, which @alchemy.run/cloudflare sends as the consumer's max_wait_time_ms.
Scope and approval
No issue or discussion exists. I'm submitting this as a very small, focused fix: for no stated reason, iOS alerts (finished, needs approval, needs input) can reach the phone up to 4 s later than Android's. The change is one value, set to the one this repo already uses for FCM. If you'd rather discuss it first, I'm happy to close this.
What changes, stated plainly:
- Wait time: when fewer than 10 deliveries are queued, an APNs delivery starts after at most about 1 s instead of 5 s.
- Invocations: at low traffic, batches are smaller, so the consumer runs more often. That's about 0.8 extra invocations per message at 1 message per second; isolated messages cost the same as today.
- Live Activities: updates keep their 15 s minimum interval (
MIN_LIVE_ACTIVITY_UPDATE_INTERVAL_MS), so the gain is mostly alerts and the first update of an activity.
Verification
- The local queue measurement above. The scripts and raw rows are in https://gist.github.com/Pyseph/0584e34a504e9dd0adae616f7eb81f16.
- The setting's path to Cloudflare: alchemy's
toConsumerSettings (@alchemy.run/cloudflare src/Queues/EventSource.ts) turns maxWaitTime into maxWaitTimeMs. The deploy path sends that as max_wait_time_ms, and the local provider maps it to miniflare's maxBatchTimeout.
- No test pins the value:
git grep maxWaitTime finds only these two consumers.
Not checked
- Production latency. You can see the real wait by comparing the start of the
relay.apn_delivery_queue.process_message span with the job's createdAt in Axiom, before and after this change.
- A 0 s timeout, which wasn't tried.
Claude Sonnet 5.5 and Claude Opus 5.5 in T3 Code (Claude Code harness).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The APNs delivery consumer kept Cloudflare Queues' default batch timeout of 5 s, so a
delivery that does not fill a batch of 10 waits the full 5 s before the consumer runs.
The FCM consumer already uses 1 s.
Approvability
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — APNs batches will wait at most one second instead of five before processing, reducing notification latency while potentially increasing batch frequency. The changed default delivery timing requires human review of that tradeoff.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Walkthrough
-
The APNS delivery queue consumer’s maxWaitTime changed from "5 seconds" to "1 second". The FCM queue consumer remains set to "1 second".
Changes: APNS delivery queue
| Layer / File(s) |
Summary |
Consumer wait time infra/relay/src/worker.ts |
The APNS delivery queue consumer’s maximum wait time changed to one second. |
Estimated code review effort: 1 (Trivial) | ~3 minutes
Change: Bug fix
Suggested reviewers: juliusmarminge, macroscopeapp
Merge Risk: Low · up to 4b17e
-
Add event-driven coverage for partial APNS batch dispatch before merging; the configuration change itself is otherwise bounded.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title clearly describes the primary change: reducing the APNs batch wait from up to 5 seconds to 1 second to match FCM. It uses a concise conventional commit format. |
| Description check |
 |
The description includes all required sections. It explains the problem, change, scope rationale, approval exception, measured verification results, limitations, and agent details. The verification se… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Description check
-
Explanation
The description includes all required sections. It explains the problem, change, scope rationale, approval exception, measured verification results, limitations, and agent details. The verification section provides specific checks and observed results rather than only stating that tests passed.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:XS
0-9 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|