Skip to content

newGig receiver loop breaks permanently after one error — later newGig events on that socket are dropped #246

Description

@JoshuaVSherman

BLOCKED by web-jam-tools#257 (do not start / do not merge PR #247 until #257 lands). PR #247's CI hung (run-all-tests timed out): removing the error-path break lets the newGig while(true) loop spin forever on a mock/stream that never signals done. The rework needs a real FULL-suite local run to catch this — which is exactly what worktrees can't do until wjt#257 restores local .env seeding. See comment below.


Problem

In src/AgController/index.ts, the newGig receiver loop breaks out of the loop on any error (around line 280):

} catch (e) {
  const eMessage = (e as Error).message;
  debug(eMessage);
  client.socket.transmit('socketError', { newGig: eMessage });// send error back to client
  break;   // <-- exits the receiver loop for the whole socket
}

Once this fires, that client socket's newGig consumer is gone — every subsequent newGig on the same socket is silently dropped (no create, no socketError, no response). The sibling handlers don't do this: editGig (editDoc, ~line 336) and deleteGig (utils.ts ~line 59) transmit the error and keep looping, so they recover on the next attempt.

How it surfaced

Found while reviewing JaMmusic PR #1252 (surfacing gig CRUD errors in the UI). That PR currently masks this bug because the frontend calls socket.disconnect() after every create/update/delete, so each gig op gets a fresh socket. If the frontend is ever changed to keep a socket open across operations (the natural optimization), the first failed create permanently wedges gig creation until reconnect.

Expected

The newGig catch block should transmit socketError and continue the receiver loop (matching editGig/deleteGig), not break. Confirm the newTour legacy alias path shares this handler and is covered.

Acceptance

  • After a newGig that throws (e.g. a validation/DB error), a subsequent valid newGig on the same socket still succeeds and publishes gigCreated.
  • A test exercises two sequential newGig transmits on one socket (first errors, second succeeds) and asserts the second is handled.

Relationship

Blocks JaMmusic#339 (the gig-CRUD-error work; PR #1252 only avoids this by disconnecting per op).

Lane: Sonnet (backend bug in src/AgController/index.ts).

🤖 Filed by Claude Code — Opus 4.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions