Repository navigation
fix: prevent Web Push broadcasts from spiking outbound requests - #103607
mikasa0818 wants to merge 7 commits into
Conversation
e7a70c4 to
176f1d8
Compare
|
Codex review: needs changes before merge. What this changesThis PR limits each Web Push broadcast to 12 concurrent sends and supplies its VAPID signing identity per request. Example: A broadcast targets 25 browser subscriptions.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR: bounded Web Push fan-out remains useful and is absent from current main and the latest release; the introduced patch has no confirmed blocking defect. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherGateway notification handlers load stored browser subscriptions and VAPID keys, invoke the Web Push transport, return delivery results, and prune expired registrations. flowchart LR
A[Gateway notification request] --> B[Subscription store]
B --> C[Broadcast scheduler]
D[VAPID identity] --> C
C --> E[Web Push HTTPS transport]
E --> F[Ordered delivery results]
F --> G[Expired subscription cleanup]
Technical reviewBest possible solution: Carry bounded scheduling and per-request VAPID identity into the current sender without weakening its delivery options or authorization ordering. Do we have a high-confidence way to reproduce the issue? Current-main and release source eagerly invoke every subscription send before awaiting completion; upstream web-push creates each HTTPS request during that invocation. Is this the best way to solve the issue? The broadcast owner and existing concurrency helper are the right fix boundary; transport retries or socket-only limits would leave eager encryption and request creation intact, but current-main integration must account for the newer shared sender. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8e234e5a43b3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +4, Tests +46. Total +50 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (25 earlier review cycles; latest 8 shown)
Reviewed October 16, 2026, 4:02 AM ET / 08:02 UTC (Revision 26). |
176f1d8 to
7a5be6e
Compare
7a5be6e to
66a425e
Compare
66a425e to
ee68cee
Compare
|
@clawsweeper re-review Proof refreshed on current head de9c69f:
The live loopback HTTPS proof cannot be re-run on this machine because Node 22.17.0 embeds SQLite 3.50.0 (below the WAL-safety floor of 3.50.7+), but the production code under test is byte-identical to the proven head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Exact-head live behavior proof on current head de9c69f (Node v24.18.0, SQLite 3.53.1): Real web-push sendNotification over HTTPS (loopback fixture, NO mock). Registered 25 subscriptions against a loopback HTTPS server: 23 ok (201), 1 gone (410), 1 missing (404). The broadcast attempted every subscription, peaked at 12 concurrent in-flight HTTPS requests (cap = 12, so bounded and concurrency genuinely occurred), returned 23 ok + 2 failed, and cleaned up both expired (410/404) subscriptions, leaving 23 retained. Production HTTPS transport transcript (current head): command: node --import tsx (real web-push, no mock) No endpoint URLs, VAPID keys, certificate material, tokens, or non-loopback addresses are included. The self-signed certificate and disabled verification were confined to the loopback fixture process. |
|
Thanks for the PR. We're closing older pull requests that have gone stale against current This PR has had no commits since July 20 and has been waiting on author changes since review. Web Push internals have moved since then; if bounded broadcast concurrency is still needed, please open a fresh PR rebased on current main. |
What Problem This Solves
Why This Change Was Made
broadcastWebPush()is the sole owner of broadcast scheduling;runTasksWithConcurrency()is the repository source of truth for ordered bounded async execution; the installedweb-pushimplementation documents and readsoptions.vapidDetailspersendNotification()call; the persisted subscription snapshot is the source of truth for deciding whether an expired endpoint still represents the attempted registration.push-web.ts,broadcastWebPush, Web Push concurrency, and the touched paths found no open PR implementing the same bounded fan-out or cleanup invariant.User Impact
web-pushencryption/request implementation against an isolated loopback HTTPS service; browser UI/service-worker behavior is unchanged by this scheduling patch.Evidence
Focused test file that validates the fix
src/infra/push-web.test.ts— drives the production broadcast ownerbroadcastWebPush()(imported fromsrc/infra/push-web.ts) over a real SQLite subscription store in a tmpdir, exercising the samerunTasksWithConcurrencyscheduling path used in production.WEB_PUSH_SEND_CONCURRENCY = 12cap), wrapswebPush.sendNotificationto trackinFlightandmaxInFlight, then assertsresults.length === 20, every resultok,maxInFlight <= 12, andmaxInFlight > 1. Proves the production scheduler caps peak outbound requests at 12 while still attempting every subscription.webPush.setVapidDetailis never called and everysendNotificationcall carries its ownoptions.vapidDetails.subject. Proves concurrent broadcasts cannot clobber module-global VAPID state.What the test proves about production behavior
Test results
pnpm exec vitest run src/infra/push-web.test.ts→ 17 passed (17/17), 1 test file passed, exit 0. Re-verified at the current PR head; all 17 tests green.pnpm lint --threads=8→ exit 0.Production HTTPS transport transcript (current head, after conflict resolution)
de9c69f49530013b9ce3c5a09e36e93d0e481e9f(Node v24.18.0, SQLite 3.53.1). Realweb-pushsendNotificationover HTTPS, NO mock. Registered 25 subscriptions pointing at a loopback HTTPS server: 23 ok (201), 1 gone (410), 1 missing (404). The broadcast attempted every subscription, peaked at 12 concurrent in-flight HTTPS requests (cap = 12, so bounded and concurrency genuinely occurred), returned 23 ok + 2 failed, and cleaned up both expired (410/404) subscriptions, leaving 23 retained. Full redacted transcript below.Additional evidence
de9c69f49530013b9ce3c5a09e36e93d0e481e9f, current main baseffc8051cacb50d1f4b39cc2c6f822083caba1f2a.pnpm exec vitest run src/infra/push-web.test.ts;pnpm lint --threads=8; earlier exact-patch validation also ranpnpm tsgo:core:test, targetedoxfmt/oxlint,git diff --check, and productionbroadcastWebPush()through a local HTTPS push-service fixture.Focused regression transcript:
Production HTTPS transport transcript (current head):
No endpoint URLs, VAPID keys, certificate material, tokens, or non-loopback addresses are included. The self-signed certificate and disabled verification were confined to the loopback fixture process.
The local Node version is below the repository's Node 22.19+ floor. The focused Vitest command used a temporary compatibility copy of the repository runner that only replaced the unsupported
import.meta.mainentry guard; project selection and Vitest configuration remained unchanged. Type checking ran through the repositorytsgocommand.AI-assisted. A local
codex review --base origin/maincould not start because the configured provider credential (MYAPI_API_KEY) is unavailable; independent read-only review found no remaining code-level actionable issues.