fix: resolve TDZ crash in useAudioRecorder and schema violations in evolution contact queries - #593
Conversation
…rets vercel.json was stored as a single base64 blob, causing Vercel to reject it with "Invalid vercel.json file provided". Decoded the content back to valid JSON. Also removed the hardcoded `env` block which contained the Supabase anon key in plaintext — environment variables must be set via the Vercel dashboard, not committed to the repository. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013jZX3jD8iLBNBqvgPVLBnE
useChatMediaSending: handleSendCustomEmoji and handleSendAudioMeme had contactPhone in their dep arrays, but getSafePhone already captures it via its own [contactPhone] dep. Redundant deps removed. useAudioManagement: startRecording called setBlobUrl inside its body but did not list it as a dep. setBlobUrl has [] deps (stable reference), so adding it satisfies the exhaustive-deps rule without causing extra renders. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013jZX3jD8iLBNBqvgPVLBnE
…volution contact queries
- useAudioRecorder.ts: move all useRef declarations and cleanupRecordingResources
useCallback above the useEffect that depends on it — previously the dep array
[cleanupRecordingResources] was evaluated at render time before the const was
initialized (TDZ), causing a ReferenceError on every mount
- useRealtimeMessages.ts: drop .schema('evo') on evolution_contacts data queries
(lines 105/136); zapp view (security_invoker=on) is canonical per CLAUDE.md rule 2;
remove stale ignore-audit comments
- useZappContactSearch.ts: same — zappSupabase already has db.schema='zapp',
so .schema('evo') override was unnecessary and bypassed the zapp view
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jZX3jD8iLBNBqvgPVLBnE
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
WalkthroughO PR ajusta o cleanup e as dependências de hooks de áudio e mídia, remove schemas explícitos nas consultas de contatos e substitui o ChangesCiclo de vida e closures dos hooks
Consultas de contatos
Configuração do deploy Vercel
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Comment |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Descrição
Três correções de bugs identificados na auditoria exaustiva de código:
1. TDZ (Temporal Dead Zone) em
useAudioRecorder.tsO
useEffectna linha 25 tinha[cleanupRecordingResources]no dep array, masconst cleanupRecordingResources = useCallback(...)só era declarado na linha 43 — DEPOIS douseEffect. Em JavaScript, dep arrays são avaliados no momento do render, antes deconstser inicializado → ReferenceError por TDZ em todo mount do componente. Fix: mover todos osuseRefecleanupRecordingResourcespara ANTES douseEffect.2. Schema violation em
useRealtimeMessages.tsQueries de dados em
evolution_contactsusavam.schema('evo'), violando a regra CLAUDE.md §2: o cliente canônico já temdb.schema='zapp'eevolution_contactsexiste como view auto-updatable emzappcomsecurity_invoker=on. Fix: remover.schema('evo')nas linhas 105 e 136; manterschema: 'evo'nas subscriptions Realtime (correto para CDC físico).3. Schema violation em
useZappContactSearch.tszappSupabase.schema('evo').from('evolution_contacts')—zappSupabaseé o mesmo cliente canônico comdb.schema='zapp', então.schema('evo')sobrescrevia desnecessariamente o schema correto. Fix: remover.schema('evo').Tipo de mudança
fix: Correção de bugChecklist de qualidade
Para todo PR
tipo: descrição em minúsculas)tsc --noEmit --skipLibCheck: 0 erros)Para PRs com
fix:Testes relacionados
Nenhum arquivo de teste novo — bugs são estruturais (TDZ de inicialização, routing de schema). A validação foi feita via:
tsc --noEmit --skipLibCheck→ 0 erroszappSupabase === supabaseviasupabaseClient.ts(mesma instância)Notas para o revisor
useRealtimeMessages.tsé marcado@deprecated— as correções de schema são válidas mesmo assim, pois mantém consistência com o restante da codebase enquanto o hook não for removido.schema: 'evo'nas linhas ~208 e ~239 estão corretas e não foram alteradas — CDC físico requer o schema da tabela raiz particionada.Generated by Claude Code
Summary by cubic
Fixes a crash in the audio recorder and aligns contact queries to the canonical
zappschema. Also repairsvercel.json, removes leaked envs, and tightens security headers.useAudioRecorderby moving refs andcleanupRecordingResourcesabove theuseEffectthat uses them..schema('evo')fromevolution_contactsdata queries inuseRealtimeMessagesanduseZappContactSearchto use thezappview; Realtime subscriptions onevoremain unchanged.contactPhoneinuseChatMediaSendingand added missingsetBlobUrlinuseAudioManagement.vercel.jsonwith valid JSON, removed committed env vars, and added stricter headers (HSTS, CSP, permissions) plus SPA rewrites.Written for commit dad9852. Summary will update on new commits.
Summary by CodeRabbit
Correções
Melhorias