Skip to content

build: resume a grant sign-in when its relay poll dies - #298

Merged
jvsena42 merged 3 commits into
mainfrom
fix/resume-grant-relay-poll
Sep 11, 2026
Merged

jvsena42 merged 3 commits into
mainfrom
fix/resume-grant-relay-poll

Conversation

@jvsena42

Copy link
Copy Markdown
Owner

Stacked on #296 (base feat/restore-grant-auth). GitHub's stacked PRs aren't enabled for this repo, so this is a plain stack: merge #296 first, then retarget this to main.

Picks up jvsena42/pubky-core-ffi-fork#7. When a grant sign-in's relay long-poll dies, the FFI restores the flow onto the same relay channel instead of failing. The approval waits in the relay inbox for ~5 minutes, so the user never approves twice.

Why

On the emulator the "HTTP transport error … httprelay.pubky.app" sign-in failure was DNS, not a cut long-poll. The full cause chain ends dns error: failed to lookup address information: No address associated with hostname: an ~18 s system-resolver timeout, then instant failures from its cache. That outlasts the time it takes to approve. Bitkit's approval was measured landing 2.7 s after Loopky had given up, in an inbox nobody read.

What's in it

  • The native libraries only: Android (4 ABIs), iOS xcframework, macOS + Linux desktop. The generated Kotlin/Swift bindings are byte-identical, so no API changes.
  • The two KDocs (RingAuthFlowHandle, loopky login) and the Architecture §13 paragraph that said a failed poll has no in-place retry now describe the resume and its bounds.
  • A journeys/RESULTS.md entry for the run below.

The resume's rules, from fork#7: it rejoins only when the failing URL is the relay's own (a homeserver-side failure comes after the approval was ACKed); it rides out ≤ 90 s of outage, backing off 1→8 s; and it stops at 170 s, just under OnboardingViewModel's 3-minute approval timeout, which can't interrupt the blocking call.

Verified on the emulator, with Bitkit as the signer

Wi-Fi + data cut for 20 s mid-wait Poll dies on the DNS error; 9 restores back off 1→8 s
Network back, approve in Bitkit Approval delivered; the resolver keeps failing for another ~43 s
A restore collects it after 33 s in the inbox session saved → SUCCESS
Revalidate · deck list ✅ · ✅
Self-tag write ❌ 403 Write to this path is not allowed (see below)

That run used a 60 s outage allowance; fork#7 ships 90 s, because 55 of the 60 were used. :shared:jvmTest (real desktop libpubkycore), :cli:test, assembleDebug and the iOS simulator build pass.

Not Loopky, but worth knowing

  • The self-tag 403 is that identity's account, not the grant. "Write to this path is not allowed" is the homeserver's per-user allowed_write_paths quota check. A grant with the same client_id and caps, for another staging account, writes the same /pub/pubky.app/tags/<id> path fine. Raised on feat: support Pubky signup synonymdev/bitkit-android#1224, together with two Bitkit quirks: it drops a deep link that arrives during its cold start, and it doesn't return via x-success.
  • Pre-existing, not addressed here: if an approval lands after OnboardingViewModel's 3-minute timeout on a healthy link, the VM reports a timeout and discards the session the FFI just collected. withTimeoutOrNull can't interrupt the blocking call (Architecture §13.10).

🤖 Generated with Claude Code

https://claude.ai/code/session_01QC3jMBnPioeidFuV1JjEQ6

jvsena42 and others added 2 commits September 10, 2026 21:43
…ll dies

Picks up pubky-core-ffi-fork#7. When a grant sign-in's relay long-poll dies, the
FFI now restores the flow onto the same relay channel, where the approval waits
in the inbox for ~5 minutes, instead of failing, so the user never approves
twice. On the emulator the failure was the relay's name not resolving through
the system resolver: an ~18s lookup timeout, longer than it takes to approve.

Native libraries only (Android's four ABIs, the iOS xcframework, the macOS and
Linux desktop rows); the generated bindings are byte-identical. The two KDocs and
the Architecture.md paragraph that said a failed poll has no in-place retry now
describe the resume and its bounds.

Verified on the emulator with Bitkit as the signer, through a 20s network cut.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QC3jMBnPioeidFuV1JjEQ6
Journey 01 with Bitkit as the signer: sign-in completes through a 20s network
cut, the session revalidates and the deck list loads. The self-tag write gets a
403 from a per-user write-path quota on that identity's staging account, not
from the grant — a grant for another account writes the same path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QC3jMBnPioeidFuV1JjEQ6
@jvsena42
jvsena42 merged commit 22eae0e into main Sep 11, 2026
7 checks passed
@jvsena42
jvsena42 deleted the fix/resume-grant-relay-poll branch September 11, 2026 00:57
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.

1 participant