Commit Graph
2 Commits
  • fix(channel): a hosted room keeps one host and outlives a failed close
    With one owner for the slot, two gaps the session's many writers hid can be
    closed in one place. A host registered over another now closes the one it
    replaces, and a restore that finds the slot taken after its store opened
    closes its own and leaves the room to that writer. A reconnect during a
    history install could otherwise leave an open store that nothing closed.
    
    The cleanup chain waits for closing to finish whatever each close returned.
    One rejected close used to leave the chain rejected, so hosting was never
    restored again in that session.
  • refactor(channel): BrowserHosting owns hosted rooms and their cleanup
    Step 6 of ADR-0015. The rooms this Browser hosts lived in two private fields
    of ChannelSession, hostedRooms and hostCleanup, written from the host_bound
    and host_input handlers, applyState, releaseHosts, restoreHosts,
    registerBrowserHost, backupOwner, installRoomHistory and closeConnection, and
    five sites extended the cleanup chain by hand. BrowserHosting in
    browser-hosting.ts now holds each open host and its binding, the chain of
    closing hosts that the next restore awaits, and the reason each stored room
    could not open, which it publishes to view.roomOpenFailures as its only
    writer.
    
    The session no longer holds hostedRooms, hostCleanup, restoreHosts,
    registerBrowserHost, browserStorage or setRoomOpenFailure. It keeps the
    connection, the request correlator, the view and the App link, and gives the
    owner six operations: view, socket, request, write, report and failures. It
    calls eight in return: host, bound, input, update, restore, register, replace
    and release. Every check after an await survives inside the owner against the
    same map entry, binding, socket and session predicate, and each sequence keeps
    its order of effects. The one reordering is in releaseHosts, where the hosts
    start closing just before the App link closes instead of just after; the two
    share no state.
    
    Behaviour is unchanged. tests/channel-session.test.ts passes 638 of 638 with
    no test edited. A new owner test shows that hosts released by an ended
    session finish closing before the next session opens the same room.