Skip to content

Conversation

@timothyfroehlich
Copy link
Owner

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.

Copilot AI review requested due to automatic review settings January 19, 2026 18:23
@vercel
Copy link

vercel bot commented Jan 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
pin-point Ready Ready Preview, Comment Jan 19, 2026 7:41pm

Copy link
Contributor

Copilot AI left a 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.sh to check if Supabase CLI is installed and running, starting it if needed
  • Updated package.json dev 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'})\"",
Copy link

Copilot AI Jan 19, 2026

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.

Copilot uses AI. Check for mistakes.
if ! supabase start; then
echo "Error: Failed to start Supabase."
exit 1
fi
Copy link

Copilot AI Jan 19, 2026

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.

Suggested change
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 uses AI. Check for mistakes.
@timothyfroehlich timothyfroehlich enabled auto-merge (squash) January 19, 2026 18:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 19, 2026 18:27
@timothyfroehlich
Copy link
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Jan 19, 2026

@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.

Copy link
Contributor

Copilot AI left a 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
Copy link

Copilot AI Jan 19, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines 1 to 21
#!/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
Copy link

Copilot AI Jan 19, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +20
else
echo "Supabase is already running."
Copy link

Copilot AI Jan 19, 2026

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.

Copilot uses AI. Check for mistakes.
* 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>
@timothyfroehlich timothyfroehlich enabled auto-merge (squash) January 19, 2026 19:39
@timothyfroehlich timothyfroehlich merged commit e934a6f into main Jan 19, 2026
17 checks passed
@timothyfroehlich timothyfroehlich deleted the chore/run-dev-starts-supabase branch January 19, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants