-
Notifications
You must be signed in to change notification settings - Fork 0
chore: ensure supabase is running before dev server starts #810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR automates Supabase startup for the development workflow by adding a pre-check script that verifies Supabase is running before the dev server starts. This prevents broken database connections during development.
Changes:
- Added
scripts/ensure-supabase.shto check if Supabase CLI is installed and running, starting it if needed - Updated
package.jsondev script to run the Supabase check before starting the Next.js dev server
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/ensure-supabase.sh | New bash script that checks for Supabase CLI installation and ensures Supabase is running |
| package.json | Updated dev script to prepend Supabase check before starting Next.js dev server |
| "description": "Pinball machine issue tracking for Austin Pinball Collective", | ||
| "scripts": { | ||
| "dev": "node --env-file=.env.local -e \"require('child_process').execSync('next dev --port ' + process.env.PORT, {stdio: 'inherit'})\"", | ||
| "dev": "bash scripts/ensure-supabase.sh && node --env-file=.env.local -e \"require('child_process').execSync('next dev --port ' + process.env.PORT, {stdio: 'inherit'})\"", |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation in README.md and docs/DEVELOPMENT.md currently instructs developers to manually run supabase start in a separate terminal before running pnpm run dev. Since this PR automates the Supabase startup, the documentation should be updated to reflect the new workflow. Consider updating README.md (line 89) and docs/DEVELOPMENT.md (lines 44-48) to indicate that pnpm run dev now automatically ensures Supabase is running.
| if ! supabase start; then | ||
| echo "Error: Failed to start Supabase." | ||
| exit 1 | ||
| fi |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script starts Supabase but doesn't verify that it's fully ready before the dev server starts. The test initialization script (scripts/supabase-init-for-tests.sh) includes a health check loop that waits for the Auth service to be ready. Consider adding a similar health check here to ensure Supabase is fully operational before the Next.js dev server attempts to connect to it. This would prevent race conditions where the dev server starts before Supabase services are available.
| fi | |
| fi | |
| # Wait for Supabase Auth service to become healthy to avoid race conditions | |
| echo "Waiting for Supabase Auth service to become ready..." | |
| MAX_RETRIES=30 | |
| SLEEP_SECONDS=2 | |
| RETRY_COUNT=0 | |
| # Default local Supabase Auth health endpoint | |
| SUPABASE_AUTH_HEALTH_URL="http://127.0.0.1:54321/auth/v1/health" | |
| while true; do | |
| if curl -fsS --max-time 2 "${SUPABASE_AUTH_HEALTH_URL}" > /dev/null 2>&1; then | |
| echo "Supabase Auth service is ready." | |
| break | |
| fi | |
| RETRY_COUNT=$((RETRY_COUNT + 1)) | |
| if [ "${RETRY_COUNT}" -ge "${MAX_RETRIES}" ]; then | |
| echo "Error: Supabase Auth service did not become ready after $((MAX_RETRIES * SLEEP_SECONDS)) seconds." | |
| exit 1 | |
| fi | |
| sleep "${SLEEP_SECONDS}" | |
| done |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@timothyfroehlich I've opened a new pull request, #811, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| # Check if supabase is running by checking the status | ||
| # We redirect both stdout and stderr because 'supabase status' can be noisy | ||
| # or report errors when stopped. | ||
| if ! supabase status &> /dev/null; then |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The health check using supabase status is simpler than the pattern used in other scripts like supabase-init-for-tests.sh which checks the Auth service health endpoint directly. Consider using a more robust health check that verifies the Auth service is actually ready by curling http://localhost:54321/auth/v1/health to ensure Supabase is not just started but fully operational. The current approach might allow the dev server to start before Supabase services are fully ready.
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Check if supabase CLI is installed | ||
| if ! command -v supabase &> /dev/null; then | ||
| echo "Error: supabase CLI is not installed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check if supabase is running by checking the status | ||
| # We redirect both stdout and stderr because 'supabase status' can be noisy | ||
| # or report errors when stopped. | ||
| if ! supabase status &> /dev/null; then | ||
| echo "Supabase is not running. Starting..." | ||
| if ! supabase start; then | ||
| echo "Error: Failed to start Supabase." | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "Supabase is already running." | ||
| fi |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script lacks documentation in scripts/README.md. While the README currently focuses on worktree sync scripts, adding a section documenting the purpose and usage of ensure-supabase.sh would improve maintainability and help other developers understand its role in the development workflow.
| else | ||
| echo "Supabase is already running." |
Copilot
AI
Jan 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script outputs messages to stdout which will be displayed every time developers run pnpm run dev. While informative, consider whether these messages provide value when Supabase is already running. The message "Supabase is already running." will appear on every dev server start, which may become noise. Consider only outputting messages when taking action (starting Supabase) or encountering errors, or making the script silent by default with an optional verbose flag.
* Initial plan * feat: add health check and update docs for automated Supabase startup Co-authored-by: timothyfroehlich <5819722+timothyfroehlich@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: timothyfroehlich <5819722+timothyfroehlich@users.noreply.github.com>
This PR updates the 'pnpm run dev' command to check if Supabase is running and start it if it's not. This prevents the dev server from starting with a broken database connection.