fix: harden unhandled rejections in main process + observability - #34
Open
RVerdiF wants to merge 1 commit into
Open
fix: harden unhandled rejections in main process + observability#34RVerdiF wants to merge 1 commit into
RVerdiF wants to merge 1 commit into
Conversation
Fase 4 of the unhandled-rejection hardening plan: - broker: catch handleAsk dispatch (Promise.all can reject mid-ask) and handlePortal residue (op=new / pre-try wiring) — answer the socket with the error instead of leaking an unhandled rejection. The internal try for portal ops is untouched. - ptyManager: defensive catch on the memory-poll interval (checkMemory). - routineService: defensive catch on the routine scheduler interval (tick). - main.ts + renderer.tsx: global unhandledRejection listeners as observability-only safety nets (structured logs, never recovery). Tests: rejection-path coverage for every new catch (broker ask explosion, portal op=new explosion, memory poll failure, tick pre-try throw).
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.
Fase 4 — hardening de unhandled promise rejections (main) + safety nets
Parte 4 do plano hardening-dogwalker-unhandled-rejections, somente processo principal e safety nets. Nenhuma mudança em
src/app/(Fases 1-3 ficam para depois).Mudanças
src/main/broker.ts—.catchno despacho dehandleAsk(oPromise.allinterno pode rejeitar, ex.: PTY morre no meio do ask) respondendo{ok:false,error}ao socket IPC;.catchno despacho dehandlePortalcobrindo o resíduo fora do try interno (op=newe wiring pré-try). O try interno (494-539) não foi duplicado.src/main/ptyManager.ts—.catchdefensivo nosetInterval(checkMemory)(poller de RAM), loga[dw] memory check failed.src/main/routineService.ts—.catchdefensivo nosetInterval(tick)do scheduler, loga[dw] routine <id> tick failed.src/main.ts—process.on(unhandledRejection)loga rejeições que escapam dos catches locais.src/renderer.tsx—window.addEventListener(unhandledrejection)loga rejeições do renderer (espelhado no stdout do main).Safety nets são APENAS observabilidade — nunca recuperação, nunca substituto de catch local (Opção B do plano, padrão PR #33).
Testes (colocalizados, cada catch novo com teste de rejeição)
src/main/broker.test.ts— ask explodindo no meio do exchange →{ok:false, error};portal op=newlançando fora do try interno →{ok:false, error}.src/main/ptyManager.test.ts— poller de memória rejeitando (listProcessesmockRejectedValue) → loga, sem unhandled rejection.src/main/routineService.test.ts—ticklançando pré-try (onUpdate) no ciclo do intervalo → loga, sem unhandled rejection.Verificação
npm run typecheck✓ ·npm run lint✓ (0 erros; 3 warnings pré-existentes) ·vitest run✓ 392/392 ·vitest run --coverage✓ (44.99/42.67/39.66/46.04 acima do ratchet 41/39/36/42)Base:
main(274d6c3) — não empilhado sobre PRs #31/#32/#33.