Skip to content

chatd waker: follow-ups from the #294 review (stalled reads, slot stall, poke gaps) #347

Closed

Description

@ibetitsmike

Coder Agents opened this issue on behalf of @ibetitsmike.

Follow-ups from the Opus pre-merge review of #344 and #345 (#294 waker). None of them is a P1, and the first two predate the waker. Tracking issue: #311.

  1. A read that does not fit the time left re-runs at once with no progress. In coderd/x/chatd/fork_wait_for_events.go, !wakeupReadFits(...) returns nil without writing anything, and fork_waker.go pokes after every nil result. With 3 or more PR watches and a stalled GitHub, PR 1 and 2 time out (30 s each), the delivery returns nil, and the redelivery reads PR 1 and 2 again. Later watches are never read and the wake-up holds a delivery slot until it expires. Fix: return a sentinel that does not poke, or write next_run_at = now + eventsPollInterval, and read watches round-robin from where the last delivery stopped.
  2. Full delivery slots stall the waker loop. dispatch blocks the single loop on k.slots <- struct{}{}. While 8 events wake-ups sit in slow reads, pokes, the timer and the sweep are not handled, so plain wake-ups of other chats wait. Fix: skip and mark the chat for another pass instead of blocking, or reserve slots for non-events kinds.
  3. Children-only events wake-ups rely on pokes and the 60 s sweep (after feat(chatd): make events wake-ups due when a watched child is done #345). A child that becomes done through a commit not published on chatd's wrapped pubsub (for example a descendant question answered over HTTP, or the child's own wake-up finishing) is seen only by the sweep: up to 60 s, against 15 s before. Fix: poke the parent's waker from those paths, or add a test proving each path publishes.
  4. New wake-ups created while the chat is idle do not poke. For example a wake-up created over the API waits for the next sweep (up to 60 s) before the timer is armed. Fix: poke after the create commit.
  5. Nits: the delivery deadline in fork_waker.go uses time.Now/time.Until, not quartz; run is one-shot, so a worker started twice on one Server has no waker (does not happen in production today).

Acceptance: a test for each of 1 to 4 that fails before the fix, plus a negative control.

Activity

  1. ibetitsmike commented on Nov 17, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    Delegated to a workstream (Opus 5.5, high) on 2026-11-17 05:50Z. Branch mike/issue-347-waker-followups, one PR on main with Closes #347.

  2. ibetitsmike commented on Nov 17, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    #376 merged 2026-11-17 08:03Z as ada0207 and resolves item 1 and the quartz nit of item 5. PR #377 covers items 2, 3, 4 and 5b and is being restacked on the new main.

  3. ibetitsmike commented on Nov 17, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    Closed by #377, merged 2026-11-17 09:03Z as 1a19c25 (items 2, 3, 4 and 5b). Item 1 and the quartz nit of item 5 were resolved by #376 (ada0207).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions