Skip to content

WatchNodes SSE: a write racing subscription registration is never delivered, blocking every push under load #2584

Closed

Description

@malibio

WatchNodes SSE stream > delivers nodeCreated event when a node is written fails every time under the pre-push gate and passes standalone in ~450ms. It has blocked four consecutive pushes today.

This was initially read as flake (and is adjacent to #2431's resource contention), but it is not: it is a deterministic race that only opens when the machine is loaded.

Not a timeout problem

First hypothesis was an under-budgeted timeout — it failed at 5012ms against a 5000ms limit. Raising the budget to 25s disproved that:

× WatchNodes SSE stream > delivers nodeCreated event when a node is written 25010ms
  → This operation was aborted

It consumed the entire 25s. The event is never delivered at all, so the connection is not merely slow. That change has been reverted (f35c6e3) rather than left in to make failures take five times longer.

The actual race

This is the only one of the three tests whose write happens inside onConnected:

// nodeCreated — creates INSIDE onConnected
onConnected: () => h.adapter.createNode({ id, ... })

// nodeUpdated / nodeDeleted — create BEFORE the stream, mutate inside
await h.adapter.createNode({ id, ... });
onConnected: () => h.adapter.updateNode(id, 1, { ... })

onConnected fires when the server's : connected comment is received, which the helper's own comment claims "guarantees the subscription is registered before any writes fire". The evidence says otherwise: there is a window between flushing that comment and the client actually being registered in sseClients for delivery. Under load the window widens, the write lands inside it, and the event is emitted to a client list that does not yet include this subscriber. Nothing arrives, ever.

The other two tests never expose this because their node already exists before the stream opens; only the mutation needs to race, and it is issued after registration has had longer to settle.

Why it matters beyond the test

The test is asserting a contract real subscribers depend on: if I have received : connected, I will receive events for writes that happen after that point. If that contract does not hold, a live UI subscriber can miss node events during its own connection setup — which is exactly the class of bug WatchNodes exists to prevent. The test is right to assert it; the server appears not to honour it.

Acceptance criteria

  • The : connected comment is emitted only after the client is registered in sseClients, so no write can be missed by a subscriber that has seen it — or, if that ordering is already intended, find why registration lags the flush
  • delivers nodeCreated passes under the pre-push gate (test:all + cargo build first), not just standalone
  • A regression test covers the loaded case rather than relying on an idle machine to pass

Reproduction

git push on a machine where the gate has just run test:all and a cargo build. Fails 4/4 that way; passes 3/3 when test:e2e is run alone.

Related

#2431 (test-gate resource contention) is the condition that exposes this, but widening timeouts does not fix it — the 25s run above is the evidence.

Activity

  1. malibio commented on Sep 13, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 240 test files passed, 4951 tests passed (83.10s)

  2. self-assigned this
    on Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions