Skip to content

fix(studio): prevent infinite render loop in new-project form#46131

Merged
joshenlim merged 1 commit into
masterfrom
fix/new-project-form-render-loop
May 20, 2026
Merged

fix(studio): prevent infinite render loop in new-project form#46131
joshenlim merged 1 commit into
masterfrom
fix/new-project-form-render-loop

Conversation

@alaister
Copy link
Copy Markdown
Member

@alaister alaister commented May 20, 2026

Fixes a "Maximum update depth exceeded" infinite render loop on /new/[slug] introduced by #46085. The symptom showed up on the internal-only configuration dropdown, but the entire form was looping.

Root cause

The new useEffect that syncs dataApiDefaultPrivileges to the experiment-driven default had form.formState in its deps. form.formState is a react-hook-form Proxy that returns a new reference on every render, so the effect refired after every render → setValue → render → effect → loop.

Fix

Pull the dirty check out of the effect into a stable boolean computed during render, and drop form.formState from the deps. Semantics unchanged — still syncs on flag resolve, still skips when the user has touched the field.

To test

  • Hard-reload /new/[slug] and confirm there's no "Maximum update depth exceeded" error in the console
  • Open the configuration dropdown (internal-only) and confirm it interacts normally
  • With the data-api-revoke-on-create-default flag off, confirm dataApiDefaultPrivileges defaults to true; with it on, defaults to false
  • Manually toggle the dataApiDefaultPrivileges field, then confirm the effect no longer overwrites your choice when the flag resolves

Summary by CodeRabbit

  • Bug Fixes
    • Fixed data API default privileges synchronization to prevent unnecessary updates and improve application stability during configuration changes.

Review Change Stack

form.formState is a Proxy that returns a new reference on every render,
so including it in the effect deps caused the dataApiDefaultPrivileges
sync effect to refire after every setValue. Pull the dirty check out of
the effect and depend on the resulting stable boolean instead.
@alaister alaister requested a review from a team as a code owner May 20, 2026 03:14
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

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

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment May 20, 2026 3:19am
studio-staging Ready Ready Preview, Comment May 20, 2026 3:19am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored May 20, 2026 3:19am
design-system Skipped Skipped May 20, 2026 3:19am
docs Skipped Skipped Open in v0 May 20, 2026 3:19am
ui-library Skipped Skipped May 20, 2026 3:19am
zone-www-dot-com Skipped Skipped Open in v0 May 20, 2026 3:19am

Request Review

@supabase
Copy link
Copy Markdown

supabase Bot commented May 20, 2026

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: abfc1e4a-6c48-47b9-99fd-28acc2b7f9d8

📥 Commits

Reviewing files that changed from the base of the PR and between d0edaef and 7c99fa6.

📒 Files selected for processing (1)
  • apps/studio/pages/new/[slug].tsx

📝 Walkthrough

Walkthrough

This PR fixes an infinite loop in the form synchronization logic for dataApiDefaultPrivileges. The effect that syncs this field with the dataApiRevokeOnCreateDefault feature flag was re-running due to form.formState changing reference every render. The refactor computes the dirty state outside the effect and removes the problematic dependency.

Changes

Form State Synchronization Fix

Layer / File(s) Summary
Effect dependency refactor
apps/studio/pages/new/[slug].tsx
Moved dirty-state computation (getFieldState(...).isDirty) to a render-time constant isDataApiDefaultPrivilegesDirty and removed form.formState from the effect's dependency array to prevent infinite re-execution while maintaining synchronization of dataApiDefaultPrivileges with the feature flag.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • supabase/supabase#46085: Directly related refactor of the same useEffect and form synchronization logic for dataApiDefaultPrivileges in the same file.

Suggested reviewers

  • pamelachia
  • awaseem

Poem

🐰 A form that syncs without the spin,
No loops of doom, just harmony in—
Dirty state computed before the run,
Dependencies fixed, synchronization won! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix: preventing an infinite render loop in the new-project form, which matches the main objective of the changeset.
Description check ✅ Passed The description fully covers the template sections with comprehensive information about root cause, fix, and testing steps, despite missing explicit YES/NO confirmation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/new-project-form-render-loop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Member

@joshenlim joshenlim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified changes on preview!

@joshenlim joshenlim enabled auto-merge (squash) May 20, 2026 03:22
@joshenlim joshenlim merged commit b28323b into master May 20, 2026
32 checks passed
@joshenlim joshenlim deleted the fix/new-project-form-render-loop branch May 20, 2026 03:23
@github-actions
Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  207 passed
flaky  1 flaky
skipped  5 skipped

Details

stats  213 tests across 23 suites
duration  4 minutes, 38 seconds
commit  7c99fa6

Flaky tests

Features › database-webhooks.spec.ts › Database Webhooks › preserves webhook URL path and custom headers after editing

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

Braintrust eval report

Assistant (master-1779247485)

Score Average Improvements Regressions
Completeness 88.5% (+19pp) 8 🟢 3 🔴
Conciseness 43.6% (+3pp) 10 🟢 7 🔴
Correctness 69.4% (+25pp) 6 🟢 1 🔴
Docs Faithfulness 67.9% (+6pp) 6 🟢 4 🔴
Goal Completion 73.1% (+18pp) 13 🟢 5 🔴
Knowledge Usage 90% (+3pp) 2 🟢 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Tool Usage 77.1% (+6pp) 2 🟢 -
Safety 95.2% (+11pp) 2 🟢 -
URL Validity 100% - -
Time_to_first_token 0tok (+0tok) 10 🟢 16 🔴
Llm_calls 6.59 (-0.1) 9 🟢 12 🔴
Tool_calls 2.95 (-0.12) 8 🟢 12 🔴
Errors 0 (-0.03) 1 🟢 -
Llm_errors 0 (-0.01) 1 🟢 -
Tool_errors 0 (+0) - -
Prompt_tokens 22621.35tok (-952.19tok) 12 🟢 11 🔴
Prompt_cached_tokens 7286.15tok (+426.67tok) 12 🟢 10 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 572.62tok (+6.35tok) 16 🟢 10 🔴
Completion_reasoning_tokens 91.36tok (-2.9tok) 10 🟢 14 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 23193.96tok (-945.85tok) 14 🟢 12 🔴
Estimated_cost 0$ (0$) 12 🟢 12 🔴
Duration 11.92s (-0.08s) 13 🟢 13 🔴
Llm_duration 8.11s (-0.49s) 18 🟢 8 🔴

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