October 24, 2026
5 pull requests merged across 1 repo
Offline-Protocol/offline-protocol-sdk
What
Two fixes to the browser binding's transports. Both were found running the Obsidian shared-folders plugin on a Mac, an Android phone (Samsung SM-M366B, Android 16, Obsidian's WebView) and an iPhone 11 (iOS 27, WKWebView), through restarts, app kills, sleep and Wi-Fi loss.
- A WebRTC connection stuck in
disconnectedis now closed (fix(bindings): close a WebRTC link stuck in "disconnected"). The carrier closed only onfailedorclosed. Android's WebView left the old connection indisconnectedfor good once the other device restarted. The engine takes one announced link per address (W3), so that dead link refused every new link from the restarted device. They never met again until a page reloaded. This happened in three restarts out of five. The carrier now closes a connection that staysdisconnectedfor 15 seconds. That is longer than Chrome's own deadline, so Chrome behaves as before. A blip that recovers inside the window cancels the close.new WebRtcCarrier(node, { disconnectedMs })sets the deadline, andInfinityrestores the old behaviour. - A hosted Nostr room stays reachable across sleep and network changes (
fix(bindings): keep a hosted Nostr room reachable across sleep).host()opened its relay sockets once. A socket that closed after the subscription went live was never dialled again. After a phone slept or lost Wi-Fi, its room answered nobody, and every join timed out with "no host answered" until the app restarted. A hosted room now does three things: - It redials a relay that drops, backing off from 1 s to 30 s.
- Every
keepAliveMs, 60 s by default, it re-sends its REQ under the same subscription id. NIP-01 says that replaces the subscription and the relay answers EOSE again. A relay that does not answer within 10 s is dropped and redialled. This covers a socket the network lost silently, which still reads as open. - It probes at once, skipping any backoff, when the page comes back
onlineor into view.
A join is unchanged.
Tests
bindings/web/scripts/test-browser.sh: 15 of 15 pages pass in Chromium, Firefox and WebKit. The first commit alone also passes all 15.webrtc.htmlgains a step that makes one end'sRTCPeerConnectionreaddisconnected. A short blip must leave the link up. A stuck connection must be closed and reported lost at both ends. The same two devices must then link again and exchange a message.nostr-signal.htmlgains two steps. In the first, the page closes every socket of a hosted room, and a later join must be answered. In the second, the room is hosted on the test relay's new/oncepath, which confirms one subscription and then goes quiet. The room must drop that socket at its next probe and dial another.- Without the source changes, both new steps fail in Chromium, with exactly the two bugs:
relay dropped: no host answered in the roomandstuck disconnected: timed out waiting for neighbor_lost. cargo test -p offline-protocol-web: 43 passed, including the guard that readsnostr-signal.js. No Rust changed.- On devices, the plugin-side versions of these fixes were run on the three devices above. After a Mac restart, 4 of 4 relinks recovered in 19 to 23 s, against 2 of 5 before. Waking the iPhone, catch-up went from 23 s to 3 to 4 s. These SDK versions have not been run on the phones yet.
Type of change
-
fix: bug fix
Breaking changes
None. Both options are new and optional. The one behaviour change is that a connection left in disconnected for 15 s now closes. In Chrome, failed already closes it sooner.
Notes for reviewers
- The documented W9 invariant changes from "closes on
failedorclosedonly" to also closing at the deadline. The reasoning is in the doc and in the comment at the top ofwebrtc.js. - In the test, the WebRTC fake calls
pc.onconnectionstatechange()directly, because Firefox does not route a page-dispatchedconnectionstatechangeto the handler. - The probe deadline is the lesser of 10 s and
keepAliveMs, so a short keep-alive never overlaps probes.
What
The browser binding could create and administer a group but never shrink it. This adds:
OfflineNode.removeFromGroup(groupId, member): the engine'sremove_from_group. The remaining members move to a new epoch whose keys the removed member never holds, and the removed member getsgroup_member_removed.OfflineNode.groupInfo(groupId): the group's members and epoch, ornullfor a group this device does not hold. For a UI that shows membership and key epochs, and for proving a removed device holds no keys.OfflineNode.start({ wasm }): the engine module as bytes or a compiled module. This is for hosts that start the worker from a Blob URL, where the glue's relative fetch of the.wasmhas nothing to resolve against. Examples: an editor plugin (Obsidian serves plugin files from another origin than the app's own) or an extension. Without the option, behaviour is unchanged.
Why
These came up building a showcase Obsidian plugin on the web binding: shared folders as MLS groups, where removing a member is the point of the demo.
Tests
- New
a_removed_member_is_told_and_the_group_moves_to_a_new_epoch(two engines over links): the removed member seesgroup_member_removed, the owner's epoch advances and the member leaves its roster, and the removed side'sgroup_infoisNone. cargo fmt --all -- --check,cargo clippy -p offline-protocol-web -- -D warnings(host andwasm32-unknown-unknown),cargo test -p offline-protocol-web --lib: 43 passed.- Built with
bindings/web/scripts/build.shand exercised in Obsidian 1.8.7 (Electron) across four vaults in two app instances: join, removal over the same-machine carrier and over WebRTC with Nostr signalling,groupInfoepochs, and start from bytes through a Blob URL worker. - Not run locally:
bindings/web/scripts/test-browser.sh(the Playwright pages). No existing page calls the new methods, so CI's Web Binding job is the check that nothing regressed.
Docs
CHANGELOG (Unreleased, Added), and docs/bridges/web.md under "What the host owes" for where the module comes from.
Why
Every pull request ran all 35 jobs whatever it touched. #621 changed only browser JavaScript and docs, and still ran about 85 runner-minutes of Rust, Java, Ruby, Python, Swift and Android work across Linux, macOS and Windows. The Actions cache was also at 10.5 GB, over the 10 GB limit, because every PR saved its own copy of 15 Rust caches and so evicted main's.
What changes
Path gating. A new Detect Changes job reads the PR's file list (dorny/paths-filter, the pinned SHA already in use) and every job is gated on a filter naming what it builds, tests or reads.
- A push to main runs everything, and so does any PR that edits
ci.yml. This PR therefore runs the full set. - Filters err wide. About fifty guards in the Rust suite read binding sources, specs, integration guides,
CLAUDE.mdand the workflows by path, sorust_testsfollows all of those. The Test matrix is cut accordingly: Linux, macOS and Windows when Rust changed, Linux alone when only a guard-read file did. - The Python filter also covers the examples and spec chapter the pytest suite reads.
- The Flutter job's own filter moved into the central job, keeping the names its guard checks for.
CI Resultpasses when every job either succeeded or was skipped by its filter, so one required check covers all of them if you add one. The repository's rulesets don't require any checks today.
Efficiency inside the jobs that run.
- rust-cache saves only from main (
save-if). - Java, Ruby and Windows C build the same debug library, so they now share one cache (
ci-uniffi-debug). - Python Bindings restores
uniffi-bindgenanduniffi-bindgen-javafrom a pinned cache instead of compiling both every run (205 s). Its three pytest runs, 6 minutes back to back, are now a parallelPython Tests (3.10 / 3.12 / 3.13)matrix over the library it uploads. This was the slowest job at about 13 minutes. - The release cdylib build runs on Linux for every PR, and on macOS and Windows only when a manifest, lockfile or build script changes. Every push to main still builds all three. That saves about 4 to 5 minutes per PR on each of the macOS and Windows legs.
What the 40 most recent merged PRs would have run
Each PR's file list was replayed through these filters with picomatch, the matcher paths-filter uses, at dot: true:
| PR | change | jobs before | jobs now |
|---|---|---|---|
| #621, #620 | browser JS + docs | 35 | License Consistency, Web Binding |
| #617 | playwright bump | 35 | License Consistency, Web Binding |
| #602 | README | 35 | License Consistency |
| #618 | react-native bump | 35 | 8 (RN, iOS, Android, Swift, Linux Test) |
| #614 | MLS engine fix | 35 | 17 (no RN, Android, Flutter, packaging, deps) |
On average 17 of 27 top-level jobs run, down from 27. The 16 full runs are mostly PRs that edited ci.yml.
The files no filter matched (CHANGELOG, ADRs, docs/bridges/{web,python,ruby}.md, docs/telemetry.md, CONTRIBUTING, dependabot.yml) were grepped across the Rust, Python, Ruby, Java, JS and shell test code. Nothing reads them except in comments.
Verification
actionlintclean, including shellcheck over everyrun:block.- The Rust guards that parse
ci.ymlpass locally:flutter_bridge_guards,build_profile,capi::ffi_tests(36) and all ofoffline-protocol-web(42). - Three docs that said a job runs "on every pull request" now say when it runs (ADR 0025,
docs/bridges/README.mdC13,docs/bridges/ruby.md).
Risk
A filter that is too narrow fails silently, because the job is skipped green. The comment on changes says so, and says a new guard reading a new path must be added to rust_tests. Main still runs every job on every push, so a miss surfaces there before a release.
Problem
The Web Binding job sometimes runs for close to an hour, and runs like 40006263164 stay stuck in "Install Playwright and its browsers".
That step normally takes 40 to 60 s. In 7 of the last 31 runs it took 11 to 52 minutes. The time goes to the apt half of --with-deps: about 190 packages, 112 MB in total, mostly WebKit's media and GTK libraries. They come from azure.archive.ubuntu.com, which sometimes crawls. From job 120550023396:
Fetched 112 MB in 51min 26s (36.4 kB/s)
The browsers come from cdn.playwright.dev and took seconds each in that same run.
The job also had no timeout-minutes, so a stall could hold it for the six-hour default.
Change
- Cache the packages:
Dir::Cache::Archivespoints apt's download directory at~/playwright-debs, whichactions/cache@v6saves between runs. Playwright's own apt call then finds every package already downloaded. - Cache key: the key is
bindings/web/package-lock.jsonplus$ImageVersion, with restore-keys. A new runner image restores the previous set, fetches only the packages Ubuntu has updated since, and saves under its own key.apt-get autocleandrops superseded versions so the cached set does not grow. - Time limit:
timeout-minutes: 30on the job. A healthy run is about 5 minutes.
Verification
- Mechanism: tested in
ubuntu:24.04. With the config in place, the first install saved its debs into the redirected directory, and a reinstall reportedNeed to get 0 B/19.2 MB of archives. This held even with Ubuntu'sdocker-cleanhook present, because the hook hard-codes/var/cache/apt/archives. - Lint:
actionlint .github/workflows/ci.ymlpasses. - On GitHub (still to do): this PR's first run starts with an empty cache, so it can still be slow, and it saves the cache when it finishes. Re-running the job should then show the step's apt log reporting
Need to get 0 B.
Follow-up to #620, which merged with six review items open. All six are fixed here, and each fix is proven by a check that fails on main.
The WebRTC carrier
- A call that rejects reports nothing. A connection reported "closed" from
offer()oranswer()even when the call rejected, naming an object the page never received. A connection now reports nothing until its call has handed the object over, and at that moment it replays the state it is already in, so no change is lost. - A connection closed while gathering makes the call reject. Before,
carrier.close()during gathering letoffer()resolve to a code for a dead connection.NostrSignaller.join()therefore published a dead offer and waited out its timeout; it now rejects at once. Its host side already catches a rejectedanswer(). - The "failed" timing in
index.d.tsis fixed. It said "about 15 s later" (than "disconnected"); Chrome reaches it 10 s after "disconnected" and 15 s after the last answered check, aswebrtc.jsandweb.mdalready said. - A try/catch that could not catch is gone.
dispatchEventnever throws for a listener's exception.
The lobby
- The host keeps inviting while a device is linked. It tried 50 times from the moment of the link. A key package slower than that left the device uninvited with nothing on screen, and nothing tried again, because the device's
secure_session_establishedhad been spent on the loop that gave up. The host now retries for as long as the link lasts, and after 10 s shows the engine's reason. - A device is saved as a member only once invited. A save while an invite was still failing (another member coming back, say) wrote the device as a member, so a reload let it back as one without an invite.
- A resumed game the node no longer holds is reported. Every invite and send failed in silence. Invites that keep failing, and 3 s of group sends that all fail with a member linked, now show the engine's reason ("Group not found: …") and point at End this game.
- The page ends with a newline again.
No Rust, UDL or wire change.
Testing
bash bindings/web/scripts/test-browser.sh: 15 of 15 pages pass in Chromium, Firefox and WebKit.webrtc.htmlhas a new step that checks both ways a call can fail: a damaged code, and a carrier closed right aftersetLocalDescription, which pins the timing exactly. Negative control: with main'swebrtc.jsit fails at that step in all three engines. Firefox rejects the offer but still reports "closed" twice.- The lobby was driven as two and three real pages, each in its own Chromium profile, linked over WebRTC with the codes a person would paste. A route-level seam on the module made the first 55 invites fail, which is more than the old fixed 50 tries. The seam is in the test harness, not in the shipped code.
| Scenario | This branch | main |
|---|---|---|
| Host, join, then the player reloads and relinks with no second invite | pass | not run |
| 55 failed invites, then the player joins | joins at about 17 s | never joins; host screen silent |
| A save while an invite is failing (3 devices) | saves C, not B | saves B as a member |
| Resumed game gone, a new device links | reason + End this game at 11 s | silent |
| Resumed game gone, a saved member returns | reason + End this game at 4 s | silent |
- Device run on a MacBook (Chrome 155) and a Samsung Galaxy M36 (Android 16, Chrome 152), in both directions, each pair on a fresh profile, recorded in
docs/bridges/web-devices.md: - link 30 to 153 ms after Connect; 10 states a second each way; host 20 to 23 store flushes a second;
- the player and then the host reloaded, in both directions: same addresses, the host still hosting the same game, the player back on its link with no second invite. A laptop already in session with the hosting phone was invited 0.1 s after the link;
- home screen and screen lock, in both directions: both pages showed "connection unstable" 11.6 to 13.3 s after the phone left the screen and the disconnect 10 s later, the host sent nothing while apart, and two new codes resumed play at 10 states a second with no backlog. After a lock the phone was unlocked by hand; its page still said the host disconnected, and two new codes resumed play;
- the paths new here, with the phone hosting: 55 failing invites showed "still trying to add" at 10.1 s and the player joined at 15.2 s, unsaved until then; a resumed game the node does not hold showed "Group not found" with End this game at 10.1 s for a new device and 3.2 s for a saved member;
- a second tab on the same account is still refused.
Found on the devices, not fixed here
- One of 20 fresh pairs never joined, and nothing on screen says so. The host's invite succeeded and it sent state; the phone never reported being added and showed no game. On a later relink the host delivered a held message that the phone decrypted, and it still did not join. That first run had no event log. 19 logged fresh pairs, three of them reloaded before linking, and a local reproduction of every other condition of that run all joined, so the cause is not known. The pair's state is kept on both devices under the profile
pr621. The new warnings cannot catch it, because no send fails on the host. A player page that is linked to its host but receives no game for a few seconds could say so; that is a follow-up.
Not covered
- The lobby harness ran in Chromium only. The page's logic does not depend on the engine.
- iPhone Safari, and the "disconnected" timing on Firefox and Safari, which were not measured on devices.
- Whether the relink in the second lock test came up behind the lock screen or after the phone was unlocked by hand: the phone was unlocked during it.