Performance optimization, applicant portal, and missing DB migration
Performance: - Convert admin dashboard from SSR to client-side tRPC (fixes 503/ChunkLoadError) - New dashboard.getStats tRPC endpoint batches 16 queries into single response - Parallelize jury dashboard queries (assignments + gracePeriods via Promise.all) - Add project.getFullDetail combined endpoint (project + assignments + stats) - Configure Prisma connection pool (connection_limit=20, pool_timeout=10) - Add optimizePackageImports for lucide-react tree-shaking - Increase React Query staleTime from 1min to 5min Applicant portal: - Add applicant layout, nav, dashboard, documents, team, and mentor pages - Add applicant router with document and team management endpoints - Add chunk error recovery utility - Update role nav and auth redirect for applicant role Database: - Add migration for missing schema elements (SpecialAward job tracking columns, WizardTemplate table, missing indexes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
34
src/lib/chunk-error-recovery.ts
Normal file
34
src/lib/chunk-error-recovery.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Detects ChunkLoadError (caused by stale builds or deployment mismatches)
|
||||
* and auto-reloads the page once to recover.
|
||||
*/
|
||||
export function isChunkLoadError(error: Error): boolean {
|
||||
return (
|
||||
error.name === 'ChunkLoadError' ||
|
||||
error.message?.includes('Loading chunk') ||
|
||||
error.message?.includes('Failed to fetch dynamically imported module') ||
|
||||
error.message?.includes('error loading dynamically imported module')
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts auto-reload recovery for ChunkLoadError.
|
||||
* Uses sessionStorage to prevent infinite reload loops (max once per 30s).
|
||||
* Returns true if a reload was triggered.
|
||||
*/
|
||||
export function attemptChunkErrorRecovery(sectionKey: string): boolean {
|
||||
if (typeof window === 'undefined') return false
|
||||
|
||||
const reloadKey = `chunk-reload-${sectionKey}`
|
||||
const lastReload = sessionStorage.getItem(reloadKey)
|
||||
const now = Date.now()
|
||||
|
||||
// Only auto-reload if we haven't reloaded in the last 30 seconds
|
||||
if (!lastReload || now - parseInt(lastReload) > 30000) {
|
||||
sessionStorage.setItem(reloadKey, String(now))
|
||||
window.location.reload()
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user