From 08f42234041951e71c5f7fa84afb2c3c2cb40b09 Mon Sep 17 00:00:00 2001 From: Till JS Date: Fri, 8 May 2026 14:10:55 +0200 Subject: [PATCH] fix(dev): cards-server uses --hot + setup-databases creates mana_notify/credits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cards-server: switch from `bun run --watch` to `bun run --hot`. --watch restarts the whole process on file change, racing the old + new Bun.serve calls for the port (the EADDRINUSE you see right after `listening on :3072`). --hot does in-process HMR via the globalThis[hmrSymbol] pattern; the port stays bound across reloads. apps/api already uses --hot for the same reason. scripts/setup-databases.sh: - create_db_if_not_exists "mana_notify" + "mana_credits" so a fresh-machine `pnpm setup:db` no longer leaves these two DBs off (mana-notify was crashing on boot with SASL fallback, mana-credits was less obvious because its drizzle config defaults to mana_platform — but the runtime config can point at mana_credits, so safer to have the DB exist). - Fix the cards branch: was pointing at the non-existent @mana/cards-database package; now points at @mana/cards-server where the actual schema lives. Verified: drop+re-create flow + cardecky:full boot + touch-trigger hot-reload all clean. --- package.json | 2 +- scripts/setup-databases.sh | 9 ++++++++- services/cards-server/package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3b7517441..a633706ea 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "dev:cards:web": "pnpm --filter @cards/web dev", "dev:cards:landing": "pnpm --filter @cards/landing dev", "dev:cards:app": "concurrently -n api,web -c yellow,cyan \"pnpm dev:api\" \"pnpm dev:cards:web\"", - "dev:cards-server": "cd services/cards-server && bun run --watch src/index.ts", + "dev:cards-server": "cd services/cards-server && bun run --hot src/index.ts", "dev:cardecky:full": "concurrently -n auth,sync,credits,notify,server,web -c blue,magenta,green,gray,yellow,cyan \"pnpm dev:auth\" \"pnpm dev:sync\" \"pnpm dev:credits\" \"pnpm dev:notify\" \"pnpm dev:cards-server\" \"pnpm dev:cards:web\"", "dev:picture:web": "pnpm --filter @picture/web dev", "dev:picture:landing": "pnpm --filter @picture/landing dev", diff --git a/scripts/setup-databases.sh b/scripts/setup-databases.sh index 03f652eb0..7f9eb84a7 100755 --- a/scripts/setup-databases.sh +++ b/scripts/setup-databases.sh @@ -131,7 +131,7 @@ setup_service() { push_schema "@mana/uload-database" "uload" ;; cards) - push_schema "@mana/cards-database" "cards" + push_schema "@mana/cards-server" "cards" ;; events|mana-events) push_schema "@mana/events" "mana-events" @@ -162,6 +162,13 @@ echo -e "\n${GREEN}Step 1: Creating databases${NC}" echo "--------------------------------------" create_db_if_not_exists "mana_platform" create_db_if_not_exists "mana_sync" +# mana-notify (Go) and mana-credits (legacy schema-filter still uses +# mana_platform but the runtime config can point at mana_credits) each +# get their own database. Without these, dev:cardecky:full crashes +# both services on boot with "database does not exist" / SASL auth +# fallback errors. +create_db_if_not_exists "mana_notify" +create_db_if_not_exists "mana_credits" echo -e "\n${GREEN}Step 2: Creating schemas in mana_platform${NC}" echo "--------------------------------------" diff --git a/services/cards-server/package.json b/services/cards-server/package.json index 48e761a28..d30e408dd 100644 --- a/services/cards-server/package.json +++ b/services/cards-server/package.json @@ -5,7 +5,7 @@ "type": "module", "description": "Cards marketplace + community backend. Owns published decks, versions, subscriptions, forks, pull-requests, discussions, moderation, and the credits-based author payout pipeline.", "scripts": { - "dev": "bun run --watch src/index.ts", + "dev": "bun run --hot src/index.ts", "start": "bun run src/index.ts", "type-check": "tsc --noEmit", "db:push": "drizzle-kit push",