From ff08ec57a24b3031ccb73df1f8a65ef6eb9d3ca8 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 04:46:03 +0000 Subject: [PATCH 1/4] fix(dev): Apply database migrations when pnpm dev starts pnpm dev did not run migrations, so the first request against a fresh database failed with `relation "junior_users" does not exist`. Run `junior upgrade` after the package builds and before Nitro and the queue worker start. It skips migrations that already ran, so it is safe on every start. Co-Authored-By: Thomas Jiang <20501235+thomasjiangcy@users.noreply.github.com> --- packages/docs/src/content/docs/contribute/development.md | 2 ++ scripts/dev-server.mjs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/packages/docs/src/content/docs/contribute/development.md b/packages/docs/src/content/docs/contribute/development.md index 8a6b77ca23..88476bcb47 100644 --- a/packages/docs/src/content/docs/contribute/development.md +++ b/packages/docs/src/content/docs/contribute/development.md @@ -41,6 +41,8 @@ pnpm dev This starts the example app on `http://localhost:3000` by default. It also rebuilds and watches the workspace packages that the example app consumes, so dashboard and runtime package edits are reflected without manually rebuilding first. +Before the app starts, `pnpm dev` runs `junior upgrade` to apply missing database migrations to `DATABASE_URL`. Migrations that already ran are skipped. Start Postgres first with `docker compose up -d postgres`. If the migrations fail, `pnpm dev` stops. + `pnpm dev` delivers background work through BullMQ on the Redis in `compose.yaml` (`redis://localhost:6382`). Start it with `docker compose up -d redis`. Local work then needs no Vercel Queues access. To use Vercel Queues, set `JUNIOR_QUEUE_PROVIDER=vercel` and run `pnpm dev:env` for the Vercel token. To use another Redis, set `JUNIOR_QUEUE_REDIS_URL`. With BullMQ, `pnpm dev` starts one queue worker process next to Nitro. Nitro accepts requests and sends jobs. The worker runs them. A new Junior build restarts both processes. A change to `apps/example/server.ts`, `plugins.ts`, `dashboard.ts` or `apps/example/app/` restarts only the worker. The worker and Nitro must share state, so `pnpm dev` keeps state in that Redis unless you set `JUNIOR_STATE_ADAPTER`. `JUNIOR_STATE_ADAPTER=memory` does not work with BullMQ. Each queue topic runs up to 4 jobs at the same time. Set `JUNIOR_QUEUE_WORKER_CONCURRENCY` to change that number. diff --git a/scripts/dev-server.mjs b/scripts/dev-server.mjs index bbf5d5b34f..fe1dbc6de1 100644 --- a/scripts/dev-server.mjs +++ b/scripts/dev-server.mjs @@ -422,6 +422,12 @@ syncInjectedPackageDist("@sentry/junior-dashboard", dashboardPackageDir, { strict: true, }); clearExampleVercelOutput(); +// Apply missing core and plugin migrations before Nitro and the worker start. +// `junior upgrade` skips migrations that already ran, so this is safe on +// every start. +runRequiredChild("pnpm", ["exec", "junior", "upgrade"], { + cwd: exampleDir, +}); spawnChild( "pnpm", From a7c04b4d52e1dbf68307b23b33c39507f01dee1a Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 04:57:35 +0000 Subject: [PATCH 2/4] fix(dev): Start compose services before pnpm dev runs migrations Run `docker compose up -d --wait` first, so `junior upgrade` finds a healthy Postgres without a manual step. Fail with a clear message when a required command such as `docker` cannot run. --- packages/docs/src/content/docs/contribute/development.md | 4 ++-- scripts/dev-server.mjs | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/docs/src/content/docs/contribute/development.md b/packages/docs/src/content/docs/contribute/development.md index 88476bcb47..66e2602a21 100644 --- a/packages/docs/src/content/docs/contribute/development.md +++ b/packages/docs/src/content/docs/contribute/development.md @@ -41,9 +41,9 @@ pnpm dev This starts the example app on `http://localhost:3000` by default. It also rebuilds and watches the workspace packages that the example app consumes, so dashboard and runtime package edits are reflected without manually rebuilding first. -Before the app starts, `pnpm dev` runs `junior upgrade` to apply missing database migrations to `DATABASE_URL`. Migrations that already ran are skipped. Start Postgres first with `docker compose up -d postgres`. If the migrations fail, `pnpm dev` stops. +Before the app starts, `pnpm dev` runs `docker compose up -d --wait`. This starts Postgres, Redis and S3 from `compose.yaml` and waits until they are healthy. Docker must be running. Services that already run are left as they are. Then `pnpm dev` runs `junior upgrade` to apply missing database migrations to `DATABASE_URL`. Migrations that already ran are skipped. If either step fails, `pnpm dev` stops. -`pnpm dev` delivers background work through BullMQ on the Redis in `compose.yaml` (`redis://localhost:6382`). Start it with `docker compose up -d redis`. Local work then needs no Vercel Queues access. To use Vercel Queues, set `JUNIOR_QUEUE_PROVIDER=vercel` and run `pnpm dev:env` for the Vercel token. To use another Redis, set `JUNIOR_QUEUE_REDIS_URL`. +`pnpm dev` delivers background work through BullMQ on the Redis in `compose.yaml` (`redis://localhost:6382`), which `pnpm dev` starts. Local work then needs no Vercel Queues access. To use Vercel Queues, set `JUNIOR_QUEUE_PROVIDER=vercel` and run `pnpm dev:env` for the Vercel token. To use another Redis, set `JUNIOR_QUEUE_REDIS_URL`. With BullMQ, `pnpm dev` starts one queue worker process next to Nitro. Nitro accepts requests and sends jobs. The worker runs them. A new Junior build restarts both processes. A change to `apps/example/server.ts`, `plugins.ts`, `dashboard.ts` or `apps/example/app/` restarts only the worker. The worker and Nitro must share state, so `pnpm dev` keeps state in that Redis unless you set `JUNIOR_STATE_ADAPTER`. `JUNIOR_STATE_ADAPTER=memory` does not work with BullMQ. Each queue topic runs up to 4 jobs at the same time. Set `JUNIOR_QUEUE_WORKER_CONCURRENCY` to change that number. diff --git a/scripts/dev-server.mjs b/scripts/dev-server.mjs index fe1dbc6de1..55ac0d790e 100644 --- a/scripts/dev-server.mjs +++ b/scripts/dev-server.mjs @@ -108,6 +108,10 @@ function runRequiredChild(command, args, options = {}) { ...options, }); + if (result.error) { + console.error(`Failed to run ${command}: ${result.error.message}`); + process.exit(1); + } if (result.signal) { process.kill(process.pid, result.signal); return; @@ -411,6 +415,11 @@ function watchForRestarts() { }); } +// Start Postgres, Redis and S3 from `compose.yaml`, and wait until they are +// healthy. Services that already run are left as they are. +runRequiredChild("docker", ["compose", "up", "-d", "--wait"], { + cwd: workspaceRoot, +}); runRequiredChild("pnpm", ["build"], { cwd: juniorPackageDir, }); From 362db17a2659975dd2b21b65c228357065e837fc Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 05:04:42 +0000 Subject: [PATCH 3/4] fix(dev): Share one compose project across worktrees Without a fixed project name, Compose names the project after the checkout folder. A worktree then starts a second project on the same host ports and pnpm dev fails with a bind error. Name the project junior so every checkout reuses the same services. --- compose.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compose.yaml b/compose.yaml index a2106f5388..02b31ca52f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,3 +1,7 @@ +# Use one project name in every checkout. Worktrees then share these services +# and ports, instead of starting a second project on the same ports. +name: junior + services: postgres: image: pgvector/pgvector:pg17 From c11204161616b644007eb5d16a62d6c8be2881b2 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 05:05:46 +0000 Subject: [PATCH 4/4] Revert "fix(dev): Share one compose project across worktrees" This reverts commit 362db17a2659975dd2b21b65c228357065e837fc. Co-Authored-By: Thomas Jiang <20501235+thomasjiangcy@users.noreply.github.com> --- compose.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/compose.yaml b/compose.yaml index 02b31ca52f..a2106f5388 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,3 @@ -# Use one project name in every checkout. Worktrees then share these services -# and ports, instead of starting a second project on the same ports. -name: junior - services: postgres: image: pgvector/pgvector:pg17