diff --git a/packages/docs/src/content/docs/contribute/development.md b/packages/docs/src/content/docs/contribute/development.md index 8a6b77ca23..66e2602a21 100644 --- a/packages/docs/src/content/docs/contribute/development.md +++ b/packages/docs/src/content/docs/contribute/development.md @@ -41,7 +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. -`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`. +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`), 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 bbf5d5b34f..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, }); @@ -422,6 +431,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",