console
console copied to clipboard
Fix/empty settings section on exit
fixes #2218
What does this PR do?
- Fixes a crash and blank-content render after exiting the Change plan flow by adding defensive guards around
$projectusage. - Prevents “Cannot read properties of undefined (reading 'region')” when navigation briefly renders before
$projectis available.
Changes
- Added null-safe checks before building links that depend on
$project.regionand$project.$id:-
src/routes/(console)/project-[region]-[project]/updateVariables.svelte- Guarded links at lines where project settings anchors are rendered.
-
src/routes/(console)/project-[region]-[project]/updateVariablesModal.svelte- Guarded the “project settings” link in the informational alert.
-
- When
$projectis not yet available, render fallback text (skeleton-friendly) instead of a link.
Why?
- Repro: Sites → any project → Settings → Resource limits → Upgrade → Cancel (or close) → Confirm exit.
- Actual: Returned to settings with empty content and console error: “Cannot read properties of undefined (reading 'region')”.
- Root cause: Components assumed
$projectwas always available; during route transitions or invalidations, it can be temporarily undefined, causing derived hrefs to throw and cascade-blank the section.
Test Plan
- Browser: Safari 18.6 on macOS Sequoia 15.6; also verify in Chrome/Firefox.
- Steps:
- Follow the repro above (including Private mode).
- Observe no console errors; sections render immediately (no blank state).
- Verify “project settings” links appear when
$projectis present, and no error occurs during the brief period before it loads.
- Additional checks:
- Open Project Settings directly; ensure links still resolve correctly.
- Trigger variable modals and ensure their internal links are guarded and functional.
Related PRs and Issues
- Resolves: runtime error “Cannot read properties of undefined (reading 'region')” originating in
updateVariables.svelteafter canceling Change plan. - Addresses: empty sections rendering on returning from the Change plan flow.
Have you read the Contributing Guidelines on issues?
Yes.
Summary by CodeRabbit
-
Bug Fixes
- Enhanced stability of project settings navigation links across multiple views and alert messages. The application now intelligently renders clickable links only when complete project context is available. When this information is unavailable, plain text is displayed instead, providing a graceful fallback that prevents broken navigation attempts.