fix(webapp): only load env var values for displayed environments#3903
Conversation
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughThis PR optimizes the EnvironmentVariablesPresenter to load variable values only for environments displayed on the page. The presenter now computes the set of environment IDs to display immediately after loading environments, then uses this set to filter the Prisma query so only values for non-archived, visible environments are fetched. This prevents loading values created by archived preview branch environments. A new test validates the behavior by setting up production and preview environments, archiving one preview branch, and confirming the presenter excludes archived environment data from results. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. 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. Comment |
The environment variables page loaded every value in the project, including rows left behind by archived preview-branch environments, which made the loader extremely slow for projects that churn branches. The values relation is now filtered to the environments the page actually displays.
bd3d417 to
d534aa9
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/plugins
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
Summary
The environment variables page loaded every variable value in the project, unfiltered by environment. Archiving a preview branch does not delete its environment variable value rows, so projects that churn preview branches accumulate values forever, and every page view loaded all of them. On large projects this made the page loader take many seconds and stalled the server while deserializing the oversized result.
Fix
The presenter now loads the displayed environments first and filters the
valuesrelation to those environment IDs. That matches the display semantics exactly (per-user dev environments and active branch environments included), and the lookup is covered by the existing unique index on(variableId, environmentId). Values in archived branch environments are no longer fetched at all.Covered by a new testcontainers test asserting that values from active environments (including branch environments) are returned while archived branch environments are excluded.