Files
buzz/mobile/lib/shared/push
Tom Brow 3ff4154ca6 fix(mobile): back off push bootstrap retries (#9092)
When push setup fails, the app retried every 5 seconds forever. On an
iPhone 12 mini whose push gateway enrollment is refused (a CDN 403 on
the installation challenge), each retry refetched the relay's NIP-11
document over a new TLS connection and logged the whole HTML refusal.
That is about 720 attempts and roughly 14 MB of traffic an hour for as
long as the app stays open, with no way to succeed.

Push registration, lease publication and tombstone retries now back off:
each consecutive failure of the same attempt doubles the delay from 5
seconds up to 15 minutes, with jitter between half and all of it so
devices that failed together don't retry together. A success (including
a renewal), a different attempt, or a channel-grammar retry (which keeps
its 5-minute delay) ends the streak. The first retry still comes within
5 seconds, so a brief blip recovers as quickly as before.

### Validation

- Added tests: `repeated failures back off exponentially up to a cap`
checks every delay's bounds at both jitter extremes over 12 failures, `a
success ends the failure streak`, and `a different attempt starts its
own backoff`. The first fails when the gate goes back to a fixed delay.
- Existing push suite passes.
- On the 12 mini before this change: `Push lease bootstrap failed` with
the 403 page and a fresh NIP-11 fetch every 5 seconds for the whole
session.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-05 11:15:22 -08:00
..