Pattern: What is the critical pattern to follow when modifying spaceG...

Documentation for Sessions

🎨 Pattern: What is the critical pattern to follow when modifying spaceG...

Date: 2026-02-10
Time: 20:42:06 UTC
Session: gspace1-103.7
Agent: angular
Confidence: 98%
Status: ✅ Documented


📋 Decision Context

Question:

What is the critical pattern to follow when modifying spaceGuard to avoid browser crashes?

Task: Document spaceGuard critical pattern to prevent future crashes


🎯 Decision Made

Chosen:

NEVER add expensive async operations (lazy imports, HTTP calls, heavy computations) to the spaceGuard's critical path without a synchronous early-exit check. The guard runs on EVERY navigation to /space/:slug/* routes. Any async work that runs before validating the slug can crash the browser tab in Vite dev mode due to module loading overhead.

Options Considered:

  1. Document as a critical pattern for future agents

💭 Reasoning

The spaceGuard has 600+ lines with: (1) lazy import('@libs-ui/auth-ui') — triggers Vite module resolution for hundreds of files, (2) initializeSpace() — HTTP calls to backend + universe loading, (3) complex branching logic for temp slugs, guest users, authenticated users. All of this runs BEFORE checking if the URL slug is valid. The FAST PATH pattern (synchronous check at the top of the guard) must be preserved for any future modifications. Similarly, never use loadComponent with barrel imports of large libraries in route configs — use static component: if the barrel is already imported.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation