Skip to content

fix(seed): await seedDatabase before SERVER_READY (closes Room-not-found race)#1041

Merged
joelteply merged 1 commit into
canaryfrom
ce/seed-sync-before-ready
May 4, 2026
Merged

fix(seed): await seedDatabase before SERVER_READY (closes Room-not-found race)#1041
joelteply merged 1 commit into
canaryfrom
ce/seed-sync-before-ready

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

Summary

carl-install-smoke intermittently fails with Room not found: general 7-21s after install completes (e.g. run 25332249956 job 74271087853 on #1038). Two fire-and-forget seed paths race the chat probe.

Root cause

  • SystemOrchestrator.startNodeServer() schedules seed via setTimeout(3000) (line 1117 pre-fix)
  • docker-entrypoint.ts main() schedules seed via setTimeout(5000) after orchestrate() returns
  • Both fire-and-forget; SERVER_READY milestone (and main's "Server ready" log) emit BEFORE seed completes
  • carl-install-smoke probes chat-send within ~14s of install — sometimes before rooms exist
  • Two parallel seedDatabase() calls can also collide on findOrCreateRoom for the same uniqueId

Fix

  • Orchestrator: await seedDatabase() BEFORE completing SERVER_READY milestone (was setTimeout fire-and-forget)
  • Drop the duplicate setTimeout in docker-entrypoint.ts — orchestrator handles it now
  • Seed becomes a precondition for "ready"; downstream sees rooms+personas+recipes guaranteed

Test plan

  • carl-install-smoke passes deterministically (no intermittent "Room not found")
  • Cold install: seed completes before SERVER_READY log, no race
  • Re-install (already-seeded DB): isSeeded() returns true, fast path
  • Mac smoke unchanged (was passing pre-fix, code path same)

🤖 Generated with Claude Code

…und race)

carl-install-smoke intermittently failed with "Room not found: general"
on the rerun for #1038 (run 25332249956 job 74271087853). Probe landed
14-21s after install completion, but seed was kicked off via
setTimeout(3000) in the orchestrator AND setTimeout(5000) in
docker-entrypoint -- both fire-and-forget, so SERVER_READY / main()
returned while rooms didn't exist yet, and chat/send threw before seed
landed.

Fix: await seedDatabase() inside SystemOrchestrator before completing
SERVER_READY, and drop the duplicate setTimeout in docker-entrypoint.
By the time anything downstream sees SERVER_READY (or the container's
node-server PID is alive past main()), rooms+personas+recipes are in
the DB and resolveRoomIdentifier("general") returns hit.

This also removes the duplicate-seed race where two parallel
setTimeouts could both call findOrCreateRoom on the same uniqueId
before the first DataCreate landed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joelteply joelteply merged commit 92e461d into canary May 4, 2026
3 of 4 checks passed
@joelteply joelteply deleted the ce/seed-sync-before-ready branch May 4, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant