Skip to content

Fix drive-app install: join fragmented WS frames, drain app agent after its folder - #1818

Closed
michielbdejong wants to merge 2 commits into
developfrom
claude/app-agent-commit-signer
Closed

michielbdejong wants to merge 2 commits into
developfrom
claude/app-agent-commit-signer

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

Fixes the host bug behind ontola/atomic-plugins#171: installing a drive app from the catalog dropped the WebSocket (1006, "Working offline"), then failed with Unauthorized. Only atomic:agent:<app> itself may create its Agent resource; the commit was signed by atomic:agent:<user>. The traces and server log are from run 36113649083.

There are two separate causes. Nothing re-signs a commit. The user-signed commit on the app agent is intended: the server accepts it through the App identities folder's append right. It fails only when it reaches the server before that folder exists.

1. The 1006: continuation frames kill the socket (server)

  • Chromium sends any WebSocket message over about 128 KB as a first frame with FIN unset plus continuation frames. A probe measured a 174 341-byte send as Binary(fin=false, 131000) followed by Continue(fin=true, 43341).
  • actix-web-actors passes these through as Message::Continuation without joining them. WebSocketConnection::handle sent that to _ => ctx.stop(), which drops the TCP connection without a Close frame, so the browser reports 1006.
  • In CI, the entry point's genesis COMMIT carries the whole plugin module. The server log shows its HTTP fallback at content-length: 174341, sent at the moment the socket dropped. So every install hit this.
  • Fix: the handler now joins fragmented text and binary messages, up to the existing 16 MiB limit. It ignores Nop, and on a protocol error it closes with a status code instead of dropping the connection. This needs actix-http as a direct dependency, for ws::Item.
  • This is not the hidden-tab liveness close from Connection drops when the tab is hidden; presence warnings after reconnect #1800 / Keep a hidden tab's socket open, and hold presence sent during subscribe #1815. The page was in the foreground, and WS traffic was continuous up to the drop, which came right as the large frame went out.

2. The 401: the reconnect drain sends agents first (@tomic/lib)

  • After the drop, serverConnected is false, so the rest of createApp gets queued in the outbox: the App identities folder, the drive pointer, the app agent under the folder, and the grants.
  • On reconnect, Store.outboxTier put every atomic:agent: subject in tier 0, so it drained before its parent folder. The server's check_append then found no parent and fell back to check_agent_self_creation, which returns 401.
  • installCatalogApp threw on that, so handOverAppKey never ran and the page never navigated. When the install did get through, the app had no key or rights on the node, which shows up as No write right on /app-write.
  • Fix: an agent whose parent is still queued drains in the normal parent-before-child depth order, not in tier 0.

Tests

  • browser/lib/src/issue-access-agent.test.ts, "an issued agent queued while offline": it queues the folder and the agent while offline, then drains against a stub server that refuses a child whose parent it hasn't seen. Before the fix it fails with the exact CI message.
  • server/tests/it/ws_fragmented.rs: sends a ~100 KB COMMIT in 32 KB fragments and expects COMMIT_OK. Before the fix it fails with Broken pipe / Connection reset by peer.
  • cargo test -p atomic-server --test it ws_: all pass. browser/lib vitest: 988 pass.

No UI changes.

🤖 Generated with Claude Code

Michiel de Jong and others added 2 commits September 25, 2026 12:18
When the socket drops during a drive-app install, the App identities
folder and the app's agent under it are both queued, and the reconnect
drain sent agents first. The server admits a user-signed Agent resource
through its parent's append right; with the folder not there yet it
falls back to "only the agent itself may create its Agent resource" and
answers 401, which failed the install (ontola/atomic-plugins#171).

An agent whose parent is itself still queued now drains in the ordinary
depth order, after that parent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chromium sends a message larger than ~128 KB as a first frame with FIN
unset plus continuation frames. actix-web-actors hands those over
unjoined as `Message::Continuation`, and the handler's catch-all stopped
the actor on them, dropping the socket without a Close frame. The
browser saw 1006 and went offline; installing a drive app, whose entry
point COMMIT carries its whole module, hit this every time
(ontola/atomic-plugins#171).

The handler now reassembles fragments up to the 16 MiB frame limit,
ignores `Nop`, and closes with a status code on a protocol error
instead of dropping the connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michielbdejong michielbdejong added bug Something isn't working server atomic-server @tomic/lib @tomic/lib labels Sep 25, 2026
joepio added a commit that referenced this pull request Sep 25, 2026
…) (#1828)

Combined batch, green on Mancave in run 4639 on 3be85ae.

Includes #1809, #1810, #1811, #1812, #1813, #1814, #1815, #1816, #1817,
#1818, #1819, #1820, #1821, #1823, #1824, #1827 and #1765, plus the e2e
label updates for #1816 and settled translation catalogs.

joepio commented Sep 25, 2026

Copy link
Copy Markdown
Member

Landed on develop in 46562ff via the combined batch #1828 (green on Mancave, run 4639). Closing.


Generated by Claude Code

@joepio joepio closed this Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server atomic-server @tomic/lib @tomic/lib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants