-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 |
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.
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 startin a separate terminal before runningpnpm 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 thatpnpm run devnow automatically ensures Supabase is running.