fix(spf): leave isComplete out of live MSF catalogs and end broadcasts per §11.3
Fixes #60
Summary
The MSF publisher wrote isComplete: true into every catalog, including those of live broadcasts. draft-ietf-moq-msf-01 §5.1.3 makes that field an irrevocable commitment that the broadcast is over, so a spec-following player or cache could treat a live stream as finished from its first catalog. Live catalogs now leave the field out, and a broadcast stopped on purpose ends with the §11.3 end-of-broadcast catalog instead.
Changes
buildMsfCatalognever emitsisCompletefor a live catalog. A newcompleteinput builds the §11.3 catalog:isComplete: truewith an emptytracksarray.- When the publish session is still
ready/liveat teardown (unpublish, endpoint change, engine destroy), the catalog track's last group is that end-of-broadcast catalog, sent after every media track has ended. A failed, closed, or GOAWAY-draining session never sends it, because a lost connection may reconnect. - The final catalog needed teardown plumbing to reach the wire:
- Track publishers gain
flushed(), which settles once every group sent so far is written and FINed. - A registered track's
end({ after })holds its subscription FINs until a last object lands. The session's existing bounded close drain waits on it, so a stalled stream can't hold up shutdown. - The session accepts stream opens during its orderly close drain, while the transport is still up. Opens are still refused once the session is destroyed, which is the case the old guard (a Chromium crash on a torn-down WebTransport) protected against.
- Track publishers gain
Behavior change worth knowing
Unpublishing and then republishing to the same namespace now looks like two broadcasts to a spec-following viewer: the first is marked complete. That matches §11.3, but the sandbox's publish toggle will now emit an end-of-broadcast catalog each time it stops. SPF's own player ignores isComplete.
The relay SDKs copied this builder and have the same bug (muxinc/relay-sdks#284). This PR doesn't touch them.
Testing
pnpm -F @videojs/spf test: new coverage for the final catalog's shape,flushed(), the deferredend({ after })inside the close drain, the unpublish path (the final catalog arrives as the last catalog object and its stream FINs cleanly, with no reset), and the session-loss path (no final catalog). I reverted each piece of the fix in turn and the matching test failed every time.pnpm lintandpnpm typecheckpass after a cleanpnpm build:packages.- Not yet verified live against a relay.
🤖 Generated with Claude Code
Summary by cubic
Fixes the MSF publisher writing isComplete: true into every catalog, including live broadcast catalogs. Since draft-ietf-moq-msf-01 §5.1.3 makes that flag an irrevocable end-of-broadcast commitment, spec-following players and caches could treat a live stream as finished from its first catalog. Live catalogs now omit the field; a broadcast stopped on purpose ends with the §11.3 end-of-broadcast catalog (isComplete: true with an empty tracks).
- Adds new teardown plumbing so the final catalog reaches the wire: a
flushed()hook on track publishers,end({ after })holding subscription FINs until the last object lands, and the session accepting stream opens during its orderly close drain. - A failed, closed, or GOAWAY-draining session never sends the final catalog, since a lost connection may reconnect.
- Unpublishing and republishing to the same namespace now appears as two broadcasts to spec-following viewers: the first is marked complete. The sandbox's publish toggle emits an end-of-broadcast catalog on every stop; SPF's own player ignores
isComplete.
Testing
- New coverage for the final catalog's shape,
flushed(), the deferredend({ after })inside the close drain, the unpublish path, and the session-loss path (no final catalog). - Lint and typecheck pass; not yet verified against a live relay.