GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines · Issue #4389 · developing-today/code

chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389

New issue
Copy link
New issue
Copy link
Closed
#4530
Closed
chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines#4389
#4530
Copy link
Assignees
dezren39
Labels
app/chatPackage/app: chat (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Nov 2, 2026
Issue body actions

Problem

app.send in pkgs/chat/main.go fans a chat message out with one new goroutine per recipient (go p.Send(msg), main.go:52-54). Nothing serializes those goroutines, so:

  1. Broadcast order is not preserved. Two messages sent in order can be delivered to a session in the opposite order whenever the first Send is delayed (a busy program, scheduler timing). Different sessions can therefore show the same conversation in different orders, and one session can show a reply before the message it answers.
  2. A stalled session accumulates unbounded goroutines. tea.Program.Send blocks until the program's update loop reads the message (or the program ends). A session that stops reading — a wedged terminal, a dead-but-not-yet-pruned connection — leaves one blocked goroutine per broadcast message, forever, with no bound, coalescing, or drop.

Evidence (main @ 30ce6be, verified this run)

  • pkgs/chat/main.go:46-55 — send copies the registry under RLock, then for _, p := range progs { go p.Send(msg) }. The go is presumably there because send is called from inside a model's Update (main.go:205-211) and the sender's own program is in the registry, so a naive synchronous Send to itself could block its own update loop — but the goroutine-per-recipient shape trades that for ordering and pile-up.
  • Laptop probe (verbatim main.go/main_test.go from current main, md5 main.go ed60f0ca59fe0cec95101087ca792655; probe dir ~/git/fleet/probe-2026-11-02-laneB-chatorder/ on the laptop):
    • PROBE1: a recipient whose Send for the text first sleeps 150 ms before recording received two broadcasts issued in order [first second] as [second first] — order inverted at one recipient.
    • PROBE2: 40 broadcasts to one recipient whose Send never returns grew the goroutine count by exactly 40 — one permanently blocked goroutine per message, unbounded.
    • The existing registry tests (TestSendReachesOnlyLivePrograms, TestRemoveUnknownIsNoOp, TestRegistryConcurrentRegisterSendRemove) all pass alongside the probes.

Why it matters

A chat room's one shared truth is the order of its messages. Today that order is per-session luck: two participants can read the same exchange in opposite orders with no error anywhere. And the pile-up half turns one stalled SSH session into slow, unbounded goroutine growth on the server for as long as the room stays busy — the registry pruning from #3201 only helps once the program actually ends, not while it is wedged.

Acceptance criteria

  • Broadcasts are delivered to each live program in the order send was called: a probe in the style of PROBE1 (a recipient whose first Send is delayed) records [first second], and a multi-recipient probe shows every recipient recording the same order.
  • A recipient that never reads cannot accumulate goroutines without bound: the fan-out drops, coalesces, or queues with a stated bound for a stalled program (PROBE2-style measurement stays bounded as broadcasts continue), and the session is still pruned normally when its program ends.
  • Sending a message from a session still delivers it to that same session (no self-send deadlock): the sender sees its own message exactly once, in order.
  • Existing pkgs/chat tests pass; new tests pin both the ordering and the bounded-stalled-recipient behaviour using the existing sender interface / fakeProg harness.

Distinct from #3201 (closed: registry never pruned — this is the fan-out call shape that fix kept, not the registry lifecycle) and from #3209 (graceful shutdown exits 1, the Start/ListenAndServe path, unrelated to send).

Activity

Next
  1. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued queue task
    app/chatPackage/app: chat (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    dezren39
    on Nov 2, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator (lane B, new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b, run 2026-11-02 08:20 CST
    • Found via: filed this run
    • Task: Triage issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 — app.send (pkgs/chat/main.go:52-54) fans each broadcast out as go p.Send(msg) per recipient, so delivery order is scheduler luck (two messages can arrive reversed at a session, and sessions disagree with each other) and a stalled session leaves one permanently blocked goroutine per broadcast, unbounded.
    • Expectation: effort/s — confirm on current main (laptop probe at ~/git/fleet/probe-2026-11-02-laneB-chatorder/, verbatim main.go @30ce6be56 md5 ed60f0ca: PROBE1 recorded [second first] for broadcasts sent [first second]; PROBE2 grew goroutines by exactly 40 for 40 broadcasts to a never-reading recipient; existing registry tests pass), then route the fix (serialized fan-out with a stated bound/drop for stalled recipients; beware the self-send deadlock a naive synchronous Send would cause, since send is called from inside Update).
    • Links: issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389; related (distinct) chat: session program registry never pruned — unbounded growth, per-message fan-out to dead programs, and a data race on the shared slice #3201 (registry pruning, closed) and chat: graceful shutdown always exits 1 — serve goroutine log.Fatalln's the expected ErrServerClosed, pre-empting the 30s drain #3209 (shutdown exit code)
  3. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    queue/queuedHas a queued queue task
    on Nov 2, 2026
  4. dezren39 commented on Nov 2, 2026

    @dezren39
    dezren39
    on Nov 2, 2026
    MemberAuthor
    More actions

    Agent note — task 6272 triage verdict: CONFIRMED on current main (lane code-k)

    • Fresh check on origin/main 381fecb60607b34288fea966c7ea5a3433310b29: pkgs/chat/main.go md5 ed60f0ca59fe0cec95101087ca792655 — byte-identical to the file this issue's probe exercised, so both probe results carry over unchanged (PROBE1 recorded [second first]; PROBE2: +40 goroutines after 40 broadcasts to a blocked recipient).
    • Code read: app.send (main.go:47-56) copies the registry under RLock, then runs go p.Send(msg) per program. Nothing serializes successive broadcasts to the same program, so delivery order per recipient is scheduler luck; and each broadcast to a stalled session parks one more goroutine in Send until that program ends — growth is unbounded and driven purely by room traffic.
    • The registry lifecycle itself is sound (chat: session program registry never pruned — unbounded growth, per-message fan-out to dead programs, and a data race on the shared slice #3201 pruning verified in the same read: remove drops finished programs; the gap is only the fan-out shape chat: session program registry never pruned — unbounded growth, per-message fan-out to dead programs, and a data race on the shared slice #3201 kept).
    • Fix routed as task 6423 (small_fix): per-recipient serialized delivery preserving send order, a stated bound on stalled-recipient goroutines (drop/coalesce/bounded queue), self-send exactly once with no Update deadlock, and tests pinning both via the sender/fakeProg harness. Excludes chat: graceful shutdown always exits 1 — serve goroutine log.Fatalln's the expected ErrServerClosed, pre-empting the 30s drain #3209 per scope.
  5. 32 remaining items

  6. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 8, 2026
  7. dezren39 commented on Nov 8, 2026

    @dezren39
    dezren39
    on Nov 8, 2026
    MemberAuthor
    More actions

    🤖 Agent note · done

    • Agent: queue worker (repo-worker-code), lane code-j
    • Session / ID: task 12158
    • Found via: queue claim
    • Task: triage task 12158 complete, outcome triaged — issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 verified real and current (bug live at pkgs/chat/main.go:55 on main; PR fix(chat): preserve broadcast order with bounded recipient queues #4530 open and unmerged)
    • Expectation: follow-up task 12687 (small_fix, dedupe repo-health:v1:fix:developing-today/code:issue:4389) is queued to land PR fix(chat): preserve broadcast order with bounded recipient queues #4530; issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 returns to the queue via queue/queued and stays open until that merges
    • Links: PR fix(chat): preserve broadcast order with bounded recipient queues #4530, task 12687
  8. developing-today commented on Nov 8, 2026

    @developing-today
    developing-todayBot
    on Nov 8, 2026 – with developing.today
    Contributor
    More actions

    🤖 Agent note · picked up

    • Agent: repo queue worker, lane code-u (repo-worker-code)
    • Session / ID: cron repo-queue-worker-shift-u run 2026-11-07 23:04 CST; task 12687
    • Found via: queue claim · task 12687
    • Task: task 12687 small_fix for issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 — land PR fix(chat): preserve broadcast order with bounded recipient queues #4530 (fix(chat): preserve broadcast order with bounded recipient queues). Execution-lane assignment returned direct. Fresh check: issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 is OPEN with no hard-stop labels; PR fix(chat): preserve broadcast order with bounded recipient queues #4530 is OPEN, unlabeled, Codex review completed with no findings (no inline Codex comments), and its diff implements exactly the packet's intent (per-recipient serialized queue, depth 16, stalled recipients pruned; order + goroutine-bound tests included). pkgs/chat/main.go:55 on current main still runs go p.Send(msg). The one defect: PR fix(chat): preserve broadcast order with bounded recipient queues #4530 is CONFLICTING with current main, so this lane rebases its branch queue/6421-4389-chat-broadcast-order (fix-forward, per the packet), verifies the chat tests, and merges it.
    • Expectation: PR fix(chat): preserve broadcast order with bounded recipient queues #4530 merged; issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 closed by the PR's closing keyword or verified closure; task 12687 completed as fixed_merged.
    • Links: task 12687 · issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 · PR fix(chat): preserve broadcast order with bounded recipient queues #4530
  9. developing-today
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    queue/queuedHas a queued queue task
    status/triagedTriaged and routed (see agent note)
    on Nov 8, 2026
  10. dezren39
    closed this as completedin #4530on Nov 8, 2026
  11. developing-today commented on Nov 8, 2026

    @developing-today
    developing-todayBot
    on Nov 8, 2026 – with developing.today
    Contributor
    More actions

    🤖 Agent note · done

    • Agent: repo queue worker, lane code-u (repo-worker-code)
    • Session / ID: cron repo-queue-worker-shift-u run 2026-11-07 23:04 CST; task 12687
    • Found via: queue claim · task 12687
    • Task: task 12687 done — PR fix(chat): preserve broadcast order with bounded recipient queues #4530 landed. The PR was CONFLICTING with current main; this lane rebased branch queue/6421-4389-chat-broadcast-order onto main (new head e8700f41b5), resolving the only conflict, in pkgs/chat/main_test.go (import union: io/os from main, runtime from the PR), plus one fix-forward the rebase exposed: main's recordingApp test helper built &app{progs: …} directly, which the PR's register-based dispatch would have pruned on first send — the helper now goes through a.register(prog). Verification: go test ./... for pkgs/chat passes on the laptop and go vet is clean; go test -race fails in TestEnterOnEmptyInputBroadcastsNothing on a bubbletea/termenv-internal race — proven pre-existing by running the same command on a clean-main worktree, where it fails identically; it is not introduced by PR fix(chat): preserve broadcast order with bounded recipient queues #4530. CI on the rebased PR head completed fully green, and the Codex review of head e8700f41b5 completed with no findings. PR fix(chat): preserve broadcast order with bounded recipient queues #4530 MERGED as ae081107baac8c87bbe18925d798bbdb30f702ae; verified on origin/main: pkgs/chat/main.go no longer fans out with go p.Send(msg) (the bounded recipientQueue with recipientQueueDepth = 16 is in place). Issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 is CLOSED by the merge.
    • Expectation: task 12687 completes as fixed_merged. The pre-existing bubbletea -race failure in the chat tests is recorded here for whichever lane next touches pkgs/chat tests; it predates and is unrelated to this change.
    • Links: task 12687 · issue chat: broadcast fan-out runs each Send in its own goroutine — messages arrive out of order and a stalled session piles up unbounded blocked goroutines #4389 · PR fix(chat): preserve broadcast order with bounded recipient queues #4530
  12. developing-today
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/chatPackage/app: chat (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.