Bugfix: How to fix authenticated user browser tab crash when navigat...
Documentation for Sessions
🐛 Bugfix: How to fix authenticated user browser tab crash when navigat...
Date: 2026-02-10
Time: 20:41:40 UTC
Session: gspace1-103.4
Agent: angular
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
How to fix authenticated user browser tab crash when navigating to a space URL that doesn't belong to them (e.g., /space/some-random-space/dashboard)?
Task: Fix browser tab crash when authenticated user visits wrong space URL
🎯 Decision Made
Chosen:
Added a synchronous FAST PATH at the top of spaceGuard (before any async operations) that checks the URL slug against the already-loaded space. If slug matches → allow immediately. If slug is unknown → redirect to current space (dev mode) or /space-not-found (subdomain mode). This completely bypasses the 600+ lines of expensive async operations (lazy import of @libs-ui/auth-ui, initializeSpace HTTP calls, loadUniverses) that were crashing the browser tab.
Options Considered:
- FAST PATH synchronous check before async operations
- Wrap async operations in try/catch with timeout
- Add URL validation middleware before guard runs
- Debounce/throttle guard execution
💭 Reasoning
The space.guard.ts is 600+ lines with heavy async operations: (1) lazy import('@libs-ui/auth-ui') which in Vite dev mode loads hundreds of modules, (2) spaceService.initializeSpace() which makes HTTP calls to backend + loads universes. When a user navigated to a non-existent space slug, ALL of these expensive operations ran before discovering the slug was invalid. Combined with Vite's per-module HTTP requests and the loading orchestrator's navigation overlay, this caused the browser renderer process to crash (tab navigated to chrome://new-tab-page/). The fix is a synchronous check BEFORE any async work: if a space is already loaded, compare the URL slug against it immediately. No network calls, no lazy imports, no crash risk.
📁 Files Involved
libs/libs-foundational/core-angular/src/lib/guards/space.guard.tsapps/gograb-space/src/app/app.routes.ts
🔗 Related
- Decision ID:
dev_1770756100422_c3r155i - Session: 103
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation