From b9b090a620ef83524cc1d699c92f0f74b345b6f8 Mon Sep 17 00:00:00 2001 From: Wanjohi Date: Sat, 5 Sep 2026 16:39:08 +0300 Subject: [PATCH] fix(deploy): stop `bun dev` when either half dies, not just the API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issuer ran in the background and nothing watched it. If it failed to bind, or exited an hour later, the API kept serving and kept reporting itself ready — while every authenticated request failed, because there was no issuer to verify a token against. That is the worst shape for a development failure: the thing you are looking at looks fine. Both run in the background now, and the script waits for either to stop before killing the other. The previous form only handled the direction where the API was the one that exited. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5f36916f..53d0a6f0 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ }, "type": "module", "scripts": { - "dev": "wrangler dev -c apps/auth/wrangler.jsonc & issuer=$!; trap \"kill $issuer 2>/dev/null\" EXIT; wrangler dev -c apps/api/wrangler.jsonc", - "dev:server": "bun run --cwd apps/auth serve & issuer=$!; trap \"kill $issuer 2>/dev/null\" EXIT; bun run --cwd apps/api serve", + "dev": "wrangler dev -c apps/auth/wrangler.jsonc & issuer=$!; wrangler dev -c apps/api/wrangler.jsonc & api=$!; trap 'kill $issuer $api 2>/dev/null' EXIT INT TERM; while kill -0 $issuer 2>/dev/null && kill -0 $api 2>/dev/null; do sleep 1; done", + "dev:server": "bun run --cwd apps/auth serve & issuer=$!; bun run --cwd apps/api serve & api=$!; trap 'kill $issuer $api 2>/dev/null' EXIT INT TERM; while kill -0 $issuer 2>/dev/null && kill -0 $api 2>/dev/null; do sleep 1; done", "dev:docker": "docker compose up --build", "db:migrate": "bun run --cwd packages/core db:migrate", "db:push": "bun run --cwd packages/core db:push",