#7578 · Cross-project notification batch recovery
BugPriority: MediumEffort: Lowremoteconfirmed-repro
REPRODUCED · root-cause confidence: high · deterministic sender-boundary reproduction
1. TL;DR
The mobile sender puts registered devices into requests by count, not by Expo project. When the transport rejects a mixed-project request, the sender abandons every device in that request and returns only the other delivery channels. A focused regression exercises registration, the actual plugin send RPC, status CLI, and read-dismissal events with a deterministic Expo transport substitute. It fails on trusted main in two clean checkouts. A ten-line sender repair splits only cross-project-rejected batches into smaller requests; all 67 plugin tests, lint, and typecheck then pass. This is not evidence of live Expo acceptance or on-device OS delivery.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| Subscriptions from different projects can share a request. | Verified | Trusted sender maps all subscriptions, then chunks only by count. The regression registers four interleaved synthetic tokens assigned to two project groups. |
| A cross-project rejection prevents mobile acknowledgement. | Verified at the plugin boundary | The transport substitute returns a request-level rejection for mixed groups. Actual RPC output omits mobile in both clean baseline runs. |
| The diagnostic failure state follows that rejection. | Supported by trusted source; guard tests also verify terminal rejection diagnostics | The request-error branch returns zero accepted deliveries and a rejection reason; the caller writes a failed outcome. |
| A standalone physical Android notification succeeded. | Unverified here | No real device, Expo account, notification manager, or production subscription was accessed. |
| The same device projects are rejected by the live Expo service. | Unverified here | The reproduction supplies a deterministic request rejection; no live external push is made. |
3. Environment
- Public repository: get-bb/bb. Trusted base commit:
da3e60b81d560e114a2bec724bb59c997aaaae7f. - Linux x86_64; Node 22.19.0; pnpm 9.15.0; Vitest 4.1.12. Provider-independent; no provider session was started.
- First run: clean target checkout. Second run: a separate fresh detached Git worktree at the same commit, with a frozen installation and only the regression patch applied.
- No app/server listener, network port, production runtime, database, or data directory was needed. The repository's plugin host harness supplies isolated in-memory plugin state.
- Frozen install succeeded. The first full build needed the documented SDK bootstrap (
build:types); after that, the normal full Turbo build completed with 74 successful tasks.
4. Minimal reproduction
The fixture deliberately models the claimed relay boundary: a request with more than one synthetic project is rejected, while homogeneous requests receive ordinary Expo ticket responses. It runs the real plugin and real subscription/sender logic, not a replacement sender. All fixture tokens are synthetic and never sent externally.
- Create a clean checkout and build its trusted dependencies:
git clone https://github.com/get-bb/bb.git bb-repro-7578 cd bb-repro-7578 git checkout --detach da3e60b81d560e114a2bec724bb59c997aaaae7f pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build
- Save the complete patch below to
/tmp/issue-7578-regression.patch, then apply it and run the regression:git apply /tmp/issue-7578-regression.patch pnpm exec turbo run test --force --filter=bb-plugin-push-notifications -- server.test.ts -t 'delivers alerts and dismissals across mixed Expo projects'
- Expected: the send RPC includes
mobile, every device is accepted exactly once, status counts every accepted ticket, and dismissals reach every project. Actual on unchanged main: the first assertion fails because the send RPC returns onlywebanddesktop.
- Expected
+ Received
{
"channels": [
"web",
"desktop",
- "mobile",
],
"ok": true,
}
Complete regression patch, including bounded-retry safety checks
diff --git a/plugins/push-notifications/server.test.ts b/plugins/push-notifications/server.test.ts
index 672b8f1a70..528e21228d 100644
--- a/plugins/push-notifications/server.test.ts
+++ b/plugins/push-notifications/server.test.ts
@@ -5,6 +5,7 @@ import {
} from "@get-bb/plugin-sdk/testing";
import { EnvHttpProxyAgent } from "undici";
import { describe, expect, it, vi } from "vitest";
+import { z } from "zod";
import {
CLIENT_NOTIFICATION_CHANNEL,
listPushSubscriptionsOutputSchema,
@@ -885,6 +886,146 @@ describe("push sender", () => {
}
});
+ it("delivers alerts and dismissals across mixed Expo projects", async () => {
+ const tokens = [
+ "ExponentPushToken[development-one]",
+ "ExponentPushToken[production-one]",
+ "ExponentPushToken[development-two]",
+ "ExponentPushToken[production-two]",
+ ];
+ const projectByToken = new Map(
+ tokens.map((token, index) => [token, index % 2]),
+ );
+ const acceptedTokens: string[] = [];
+ const expo = createFakeExpo();
+ const host = await setup({
+ expo,
+ dismissReadNotifications: true,
+ fetch: async (url, init) => {
+ const batchTokens = z
+ .array(z.object({ to: z.string() }))
+ .parse(JSON.parse(init.body))
+ .map((message) => message.to);
+ if (
+ new Set(batchTokens.map((token) => projectByToken.get(token))).size >
+ 1
+ ) {
+ return {
+ ok: false,
+ status: 400,
+ text: async () =>
+ JSON.stringify({
+ errors: [{ code: "PUSH_TOO_MANY_EXPERIENCE_IDS" }],
+ }),
+ };
+ }
+ acceptedTokens.push(...batchTokens);
+ return expo.fetch(url, init);
+ },
+ });
+ try {
+ for (const token of tokens) await host.addSubscription(token);
+ const thread = host.setThread();
+ await expect(
+ host.harness.behavior.callRpc("notifications.send", {
+ title: "Cross-project delivery",
+ threadId: thread.id,
+ }),
+ ).resolves.toEqual({ ok: true, channels: ["web", "desktop", "mobile"] });
+ expect([...acceptedTokens].sort()).toEqual([...tokens].sort());
+ const status = await host.harness.behavior.runCli(["status", "--json"]);
+ expect(JSON.parse(status.stdout).lastSendOutcome).toMatchObject({
+ status: "sent",
+ sentCount: tokens.length,
+ });
+
+ acceptedTokens.length = 0;
+ expo.requests.length = 0;
+ await host.harness.behavior.emitThreadEvent("experimental_thread.read", {
+ thread: { ...thread, lastReadAt: 200 },
+ });
+ await vi.waitFor(() =>
+ expect([...acceptedTokens].sort()).toEqual([...tokens].sort()),
+ );
+ expect(expo.requests.flat()).toHaveLength(tokens.length);
+ expect(
+ expo.requests
+ .flat()
+ .every((message) => message.data.kind === "dismiss"),
+ ).toBe(true);
+ expo.ticketErrors.set(
+ "ExponentPushToken[production-one]",
+ "DeviceNotRegistered",
+ );
+ expo.ticketErrors.set(
+ "ExponentPushToken[development-two]",
+ "MessageRateExceeded",
+ );
+ await expect(
+ host.harness.behavior.callRpc("notifications.send", {
+ title: "Partial",
+ }),
+ ).resolves.toEqual({ ok: true, channels: ["web", "desktop", "mobile"] });
+ const failedStatus = await host.harness.behavior.runCli([
+ "status",
+ "--json",
+ ]);
+ expect(JSON.parse(failedStatus.stdout).lastSendOutcome).toMatchObject({
+ status: "failed",
+ reason: "relay rejected one or more tickets",
+ });
+ const listed = listPushSubscriptionsOutputSchema.parse(
+ await host.harness.behavior.callRpc("pushSubscriptions.list", {}),
+ );
+ expect(
+ listed.subscriptions.map((subscription) => subscription.id),
+ ).toEqual(["subscription-1", "subscription-3", "subscription-4"]);
+ expect(JSON.stringify(host.harness.logEntries)).not.toContain(
+ "ExponentPushToken",
+ );
+ } finally {
+ await host.cleanup();
+ }
+ });
+
+ it.each([
+ { code: "PUSH_TOO_MANY_EXPERIENCE_IDS", subscriptionCount: 1 },
+ { code: "TOO_MANY_REQUESTS", subscriptionCount: 2 },
+ ])(
+ "does not split $code for $subscriptionCount subscriptions",
+ async ({ code, subscriptionCount }) => {
+ let attempts = 0;
+ const host = await setup({
+ fetch: async () => {
+ attempts += 1;
+ return {
+ ok: false,
+ status: 400,
+ text: async () => JSON.stringify({ errors: [{ code }] }),
+ };
+ },
+ });
+ try {
+ for (let index = 0; index < subscriptionCount; index += 1) {
+ await host.addSubscription(`ExponentPushToken[device-${index}]`);
+ }
+ await expect(
+ host.harness.behavior.callRpc("notifications.send", {
+ title: "Rejected",
+ }),
+ ).resolves.toEqual({ ok: true, channels: ["web", "desktop"] });
+ expect(attempts).toBe(1);
+ const status = await host.harness.behavior.runCli(["status", "--json"]);
+ expect(JSON.parse(status.stdout).lastSendOutcome).toMatchObject({
+ status: "failed",
+ reason: "relay rejected the request",
+ });
+ } finally {
+ await host.cleanup();
+ }
+ },
+ );
+
it("warns once per hour for network failures and logs only row ids", async () => {
let now = 10_000;
const host = await setup({
5. Root cause
Subscription batching and outcome aggregation create one delivery per subscription and split solely at the 100-message request limit:
const deliveries: Delivery[] = rows.map((subscription) => ({
subscription,
message: {
to: subscription.expoPushToken,
title,
body,
data: { ...data, subscriptionId: subscription.id },
sound: "default",
channelId: "threads",
priority: "high",
},
}));
let sentCount = 0;
let failure: string | null = null;
for (const batch of chunks(deliveries, EXPO_PUSH_BATCH_SIZE)) {
const result = await sendBatch(batch);
sentCount += result.sentCount;
failure ??= result.failure;
}
await setLastOutcome(
failure === null
? { status: "sent", at: now(), sentCount }
: { status: "failed", at: now(), reason: failure },
);
return sentCount > 0 ? [...channels, "mobile"] : channels;
The request-error branch treats every error code as terminal and returns no accepted deliveries:
if (parsed.data.errors && parsed.data.errors.length > 0) {
const codes = parsed.data.errors.map((error) => error.code ?? "unknown");
bb.log.warn(
`Expo push request was rejected with codes ${codes.join(", ")}`,
);
return { sentCount: 0, failure: "relay rejected the request" };
}
Thus a mixed-project rejection affects unrelated valid devices together. Individual tokens carry no locally stored Expo-project partition, and the sender neither learns a partition nor narrows a rejected request. Read-dismissal pushes share the same batch sender, so fixing only notification creation would miss that path.
6. Proposed fix and verification
For PUSH_TOO_MANY_EXPERIENCE_IDS only, split a rejected batch in half and retry its two halves. Stop splitting at one subscription. Preserve each delivery object so ordinary ticket indexing, unregistered-device removal, accepted-ticket counts, and failure aggregation still work. Other request failures and network failures retain their existing behavior. Successful homogeneous batches are not resent.
This avoids new project metadata, persisted state, schema changes, public protocols, dependencies, or external response-details parsing. The tradeoff is extra relay requests whenever a batch mixes projects: a completely interleaved batch can use up to 2n − 1 requests including failed parents; recursion depth is logarithmic, and each original batch has at most 100 deliveries. An optimization that caches project partitions is intentionally outside this contained fix.
Local repair: 10 production additions and 141 test additions across two files, 151 total changed text lines. The regression checks successful alert delivery and diagnostic counts, dismissal delivery, ticket failure propagation, removal of the correct unregistered row after splitting, and token-free logs. Two guard cases prove no repeated request for an already-singleton cross-project rejection or an unrelated request error.
pnpm exec turbo run test lint typecheck --filter=bb-plugin-push-notifications Test Files 3 passed (3) Tests 67 passed (67) Tasks: 10 successful, 10 total git diff --check (no output; exit 0)
7. Linked PR review
PR #7579 was closed without merging when inspected. Only its GitHub metadata and textual diff were read as untrusted data; its branch and tests were never checked out or executed. Its diff parses relay-supplied project groups, validates the token partition, and caches project assignments for later batching. That statically targets the same request-batching cause, but only when the rejection supplies the expected partition details. No runtime verdict is claimed for that closed patch. No open linked PR existed when the simple-fix check ran.
8. Related issues
A small repository issue search showed other notification-platform reports and notification routing requests, but no second confirmed duplicate was established. This report addresses only #7578.
9. Verification: second clean reproduction
The same investigator created a second clean detached worktree at da3e60b81d560e114a2bec724bb59c997aaaae7f, ran a frozen installation, and applied only the regression-test patch. The production sender remained unchanged. The exact focused command from section 4 was repeated with --force so it executed rather than replaying cached test output. It failed with the same missing mobile channel, supporting the root cause and final verdict. This is repeat verification by the same investigator, not independent review.
The final test patch was rerun there after a test-only compatibility adjustment from toSorted() to copying plus sort() for this package's configured TypeScript library. The failure remained the intended RPC-channel assertion. No report conclusion changed.
10. Appendix and limits
The regression was added and observed failing before the production repair. The second checkout independently of the working files (but not independently of the investigator) repeated that failure. After the repair, the complete owning plugin suite passed, alongside lint and typecheck. No broad unrelated test sweep, hardware test, or visual test is claimed. The selected notification feature recipes for closed-app OS delivery and physical-device permissions remain unrun because test mobile hardware and credentials were not supplied.
Evidence operations: repository and issue-property reads; trusted-main fetch and commit verification; frozen install; SDK bootstrap and full Turbo build; two focused baseline runs; owning-plugin tests, lint, typecheck, formatting, and diff checks; static metadata/diff inspection of the closed linked PR. Issue content was treated only as hypotheses; no issue-provided script or external link was executed or fetched.
Raw machine-path-containing logs and local reproduction artifacts remain outside the published Git history. The report embeds the complete test patch and the relevant exact expected-versus-actual output, so no private artifact is needed to repeat it.