fix: improve stability with lazy loading, error boundaries, and stora… - #1
Draft
BrenoACarvalho wants to merge 1 commit into
Draft
fix: improve stability with lazy loading, error boundaries, and stora…#1BrenoACarvalho wants to merge 1 commit into
BrenoACarvalho wants to merge 1 commit into
Conversation
…ge protection - Replace static JSON imports with dynamic import() in lib/curriculum.ts and lib/offers.ts (reduces initial bundle from ~1.3MB to only what's needed for the selected course) - Add global-error.tsx and route-level error.tsx files to prevent white screen crashes - Add loading.tsx files for graceful loading states - Fix useAppStore snapshot to use stable reference (getState directly) - Add try/catch to all localStorage writes to prevent QuotaExceededError crashes - Add 300ms debounce to weekly planner localStorage persistence - Update hooks (use-course-data, use-available-classes) to handle async data loading - Update setup-dialog and other-offerings-dialog to load data lazily Co-authored-by: Breno Carvalho <28658627+BrenoACarvalho@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Correções de Estabilidade
Este PR resolve os principais problemas que causam quedas frequentes (tela branca, travamentos, crashes) no aplicativo.
Mudanças principais:
1. Lazy Loading dos dados JSON (~1.3MB → sob demanda)
lib/curriculum.tselib/offers.tsagora usamimport()dinâmico2. Error Boundaries (previne tela branca)
app/global-error.tsx— captura erros fatais no root layoutapp/error.tsx— captura erros genéricos de rotaapp/flow/error.tsx— erro específico para o fluxogramaapp/simulation/error.tsx— erro na página de simulaçãoapp/s/error.tsx— erro na grade compartilhada3. Loading States
4. Proteção do localStorage
try/catchem todos oslocalStorage.setItem(previne crash porQuotaExceededError)5. Otimização do Store
useAppStoreagora usa referência estável nouseSyncExternalStoreTestado:
npx tsc --noEmit— sem erros TypeScriptnpx next build— build completo (11 páginas estáticas)