Skip to content

Log the desktop host's uncaught exceptions instead of showing Electron's dialog - #686

Merged
yansfil merged 5 commits into
mainfrom
fix/flaky-675
Oct 7, 2026
Merged

yansfil merged 5 commits into
mainfrom
fix/flaky-675

Conversation

@yansfil

@yansfil yansfil commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #675

Summary

  • 원인(hang 경로): desktop host main process에서 아무도 잡지 않은 예외가 나면 Electron 기본 처리기가 오류 대화상자(NSAlert runModal)를 띄운다. 그 모달이 열려 있는 동안 quit이 끝나지 않아, browser-cdp.spec.ts의 afterEach가 180초를 기다렸다.
    • TEMP CI(retry 0)에서 60회 중 49번째에 재현. host log는 host.quit에서 끝났고, 3분 뒤 sample에서 main thread가 JS(타이머 -> microtask)에서 부른 NSAlert runModal에 머물러 있었다.
  • 수정: host가 uncaughtException과 unhandledRejection을 한 곳(desktop/src/main/uncaught.ts, index.ts에서 등록)에서 받아 desktop.log에 host.uncaught {kind, message, stack}로 남기고 계속 돈다. Electron 기본과 같되 모달만 없다.
    • message와 stack의 주소는 scheme만 남기고(https://[address]), token 같은 secret 모양은 기존 redact로 지운다. host log가 daemon URL을 싣지 않는다는 규칙을 지키기 위해서다.
  • desktop e2e fixture는 cleanup에서 host.uncaught가 있으면 home을 지운 뒤 stack을 붙여 테스트를 실패시킨다. 테스트가 일부러 낸 것은 allowHostUncaught로 표시한다.
  • 예외 자체는 미확인이다: 예외를 기록하는 계측 run 570회에서 다시 나지 않았다. 다음 발생은 fixture가 stack과 함께 실패시키므로 hang 대신 원인이 남는다.

Review

  • 판단해 주세요: 제품 동작 변화. main process에서 잡히지 않은 예외가 나도 운영자에게 Electron의 "A JavaScript error occurred in the main process" 대화상자가 더 이상 뜨지 않고 desktop.log의 host.uncaught로만 간다(설계 원칙 13: 알림, 배너, 시트는 PRD 결정이지 기본값이 아니다). 그 모달은 quit도 막았다.
  • 조심해서 볼 파일:
    • desktop/src/main/uncaught.ts - failure path. 두 listener가 Electron 대화상자와 Node의 rejection->exception 변환을 대신한다. 앱이 계속 도는 것은 Electron 기본과 같다.
    • desktop/e2e/fixture.ts - cleanup이 이제 host.uncaught로 테스트를 실패시킨다. 지금까지 모달 없이 지나가던 예외가 다른 spec에 있었다면 이 PR의 desktop e2e에서 드러난다.
    • web/src/redact.ts - redact를 settings.ts에서 옮겼다. main process가 settings.ts를 타입만 import해도 shell store와 React 모듈까지 typecheck에 끌려와서, ARCHITECTURE의 "main process는 shell store를 import하지 않는다"를 지키려고 분리했다. 동작은 같다.

Evidence

  • 확인한 것:
    • 결정적 desktop e2e uncaught: - main에 일부러 예외와 rejection을 심고, 둘 다 host.uncaught로 남는지(redact 포함), 앱이 계속 도는지, app.close() 뒤 exit code 0으로 끝나는지 본다. TEMP CI 수정 전/후 아래 표.
    • fixture unit: 허락하지 않은 host.uncaught는 home을 지운 뒤 stack과 함께 cleanup을 실패시키고 한 번만 보고한다. 허락한 것은 통과.
    • 로컬: desktop typecheck, lint, unit 158, build 통과. web typecheck, lint, unit 1164, design contract 통과.
  • 확인하지 못한 것: #675의 원래 예외가 무엇인지(재현 570회 중 0회). 로컬 desktop e2e는 돌리지 않음(디스크 부족으로 cargo build 불가), CI가 증거다.
검사 (TEMP CI, retry 0) 수정 전 수정 후
desktop e2e uncaught: (macOS) x2: 2/2 실패. host.uncaught 없음(poll 5 s 초과), close 뒤 앱이 끝나지 않음(candidate exit unconfirmed) x10: 10/10 통과, 1.5-7.3 s
desktop e2e 전체 (이 PR CI) 60 통과, 7 skip, flaky 없음: 다른 spec에서 새로 드러난 host.uncaught 없음

…and quit still finishes

The desktop e2e fixture now reads the host log on cleanup and fails a
test whose host recorded host.uncaught it did not cause on purpose,
with the stack, after the home is deleted. The new desktop test plants
an exception and a rejection in the main process and expects both in
the log, redacted, with the app still running and quit finishing.
…n's dialog

An exception or rejection nothing in the main process caught showed
Electron's default error dialog, a modal the operator can do nothing
with that also holds quit until it is answered; a desktop e2e quit
waited behind it until the test timed out. The host now records it as
host.uncaught (kind, message, stack, with addresses cut to their scheme
and secret-shaped runs redacted) and keeps running, as Electron's
default does. redact moves to its own module so the main process can
use it without reaching the shell's store.
@yansfil
yansfil merged commit e8a8ea3 into main Oct 7, 2026
17 checks passed
@yansfil
yansfil deleted the fix/flaky-675 branch October 7, 2026 02:08
yansfil added a commit that referenced this pull request Oct 7, 2026
…n agent choice does not cover the shell (#698)

Refs #412 (nightly run 37541045200, package (macos))

## Summary

- 실패: nightly package (macos)의 `server-session-search.spec.ts` "server
picker and conversation search in a background native window"가 두 시도 모두
`getByRole('button', { name: /^Settings \(/ })`를 30초 동안 찾지 못했다.
- 원인: 이 lane은 packaged app을 띄우고, packaged daemon은 이 Mac의 kit을 돌린다.
Settings 정리(#668)부터 kit은 kit 기록이 없는 HOME을 첫 실행 agent
선택(`agent_onboarding: pending`)으로 붙잡고, 셸은 Apply로만 닫히는
modal(`AgentOnboarding`)을 띄운다. modal은 나머지 셸을 접근성 트리에서 숨기므로 sidebar의
Settings 버튼이 role로 잡히지 않는다.
- 제품 결함이 아니다: Settings icon 버튼은 `Hint`가 준 `aria-label` "Settings (⌘,)"를
그대로 갖는다. 테스트가 첫 실행이 아닌 HOME을 가정한 것이다.
- 수정: kit spec들이 이미 쓰는 방식(`device-home.ts`의 `seedKitRecord`: 빈 kit 기록으로
"kit이 돈 적 있는 머신"을 만든다)을 이 spec에도 적용했다. 첫 실행 dialog 자체는 web e2e
`agent-onboarding.spec.ts`와 core 결정 테스트가 따로 지킨다.
- PR의 desktop e2e lane에서는 같은 spec이 통과해 왔다: 그 lane의 debug daemon은 kit을
돌리지 않아 첫 실행 dialog가 뜨지 않는다.

## Review

- **조심해서 볼 파일**: `desktop/e2e/server-session-search.spec.ts` - kit 기록을
모든 lane에서 심는다. debug daemon은 kit을 돌리지 않으므로 desktop e2e lane에는 영향이 없다.

## Evidence

- **확인한 것**:
- nightly 실패 시점 hided 로그에 packaged kit의 `apply.completed`가 있고, 같은 spec이
PR desktop e2e(debug daemon)에서는 통과(#686 run, 11.6 s).
  - desktop typecheck, lint(test size 포함) 로컬 통과.
  - macOS package lane TEMP workflow_dispatch(retry 0) 수정 전/후: 아래 표.
- **확인하지 못한 것**: 로컬 packaged app 실행(release build가 디스크 하한을 넘김). macOS
증거는 TEMP CI다.

| macOS package lane (TEMP dispatch, retry 0) | 수정 전 (main) | 수정 후 |
|---|---|---|
| server-session-search "server picker ..." | 실패: Settings `getByRole`
30 s 초과 (run 37564888317) | 통과 16.1 s (run 37564891413) |
| local-kit | 통과 | 통과 |
yansfil added a commit that referenced this pull request Oct 7, 2026
Refs #412 (nightly package (macos) 실패 class를 PR desktop e2e lane에서 잡는 쪽)
Related: #698 (이 PR이 그 spec의 seed 줄을 지운다), #700

## Summary

- 문제: desktop e2e lane의 daemon은 `target/debug`에서 돌아 install kit을 돌리지
않는다. packaged daemon만 kit을 돌리므로, kit이 만드는 상태(#668의 첫 실행 agent 선택 modal)와
spec의 충돌이 nightly package lane(#412)에서야 드러났다.
- 수정: `web/e2e/bundled-app.ts`가 debug 바이너리 셋(`hided`, `hide`,
`hide-agent-hooks`)을 worker당 하나의 `hide.app/Contents/Resources` 배치로
hardlink한다. desktop `isolate()`는 앱의 `HIDE_CLI_PATH`를 이 bundle의 `hide`로
둬, daemon이 packaged와 같이 kit을 private HOME에 돌린다.
- web의 `bundledBinary`(daemon마다 복사본)는 지우고 같은 helper를 쓴다. bundle은 앱이나
daemon이 그것으로 뜰 때 만들어, 아무것도 띄우지 않는 fixture(unit suite)에는 build가 필요 없다.
- `isolate()`는 기본으로 빈 kit 기록(`seedKitRecord`)을 심는다. 첫 실행을 보는 spec은
`~/.hide/kit/installed.json`을 지운다(지금 desktop에는 없다: 첫 실행 dialog는 web
`agent-onboarding`과 core/hide-kit 테스트가 지킨다).
- 그래서 spec마다 두던 seed(`home-layout`, #698의 `server-session-search`)는 지운다.

## Review

- **판단해 주세요**: desktop e2e의 모든 launch가 이제 kit을 돈다(CLI link, hook 진단, 은퇴
pass). packaged 동작과 같아지는 대신 kit 실패가 desktop spec 실패로 나타난다.
- **조심해서 볼 파일**:
  - `web/e2e/bundled-app.ts` - failure path와 정리.
- bundle은 `target/debug/e2e-apps/<pid>/`에 둔다. Windows runner의 temp가 다른
드라이브라 hardlink가 넘을 수 없어서다.
- worker 종료 때 지운다. 그 exit handler는 `worker-owned`의 것(소유 daemon 정지) 뒤에
돈다.
- 죽은 worker의 bundle은 다음 bundle을 만들 때 지운다(rebuild 뒤 옛 inode가 디스크에 남는 것을
막는 cap).
- `desktop/e2e/fixture.ts` - `start()`가 앱의 `HIDE_CLI_PATH`가 bundle일 때만
link한다. `hide` helper와 cleanup의 `hide stop`은 `HIDE_CLI`(target/debug)를
그대로 쓴다. 같은 내용이라 build id가 같다.
- **비용 검토**: launch당 추가 시간은 따뜻한 launch 14쌍에서 중앙값 +54 ms, 평균 +61 ms(범위
-131~+267 ms)다. 아래 표.

## Evidence

- **확인한 것**:
- TEMP desktop e2e lane(macOS, `server-session-search` x3, retry 0)의 전후
결과와 launch 시간: 아래 표.
- nightly의 `@platform` lane을 이 브랜치로 따로 돌렸다(nightly concurrency group과
분리).
- desktop e2e: Linux 6/6, Windows 6/6 통과(run 37568682822, 37568686414).
    - web e2e Windows `@platform`도 통과.
- desktop unit 158개, web과 desktop의 typecheck, lint(test size 포함) 로컬 통과.
- 이 PR의 full run(run 37570292612): desktop e2e 60
passed(`server-session-search` 12.6 s), web e2e, checks, windows check
통과. verify
https://github.com/modakbul-gongbang/hide/actions/runs/37570292612/job/112633982739
- **확인하지 못한 것**:
- Linux와 Windows에서 kit이 실제로 돌았는지는 통과한 run의 로그로 보이지 않는다. bundle 판별은 이름
기반이라 OS와 무관하다(`hide_kit::bundled_kit_dir` 테스트).
- kit의 Herdr integration 행: bundle에 herdr를 넣지 않아(web bundle과 같다) "Herdr
CLI 없음"으로 읽힌다. 그 행을 보는 spec이 생길 때 그 PR에서 link한다.
- 이 run의 첫 launch(3.9 s, bundle)는 runner의 첫 Electron 기동이라 bundle 비용과 가를
수 없어 위 통계에서 뺐다. 바로 뒤 debug launch는 1.5 s였다.

| TEMP desktop e2e lane, retry 0 | 결과 |
|---|---|
| bundle만, 기본 kit 기록 없음 (run 37568547117) | `server-session-search` 3/3
실패: `getByRole('button', { name: /^Settings \(/ })` 30 s 초과, nightly
#412와 같은 신호 |
| 이 PR (run 37568584039) | 3/3 통과(12.7-14.8 s) |
| launch에서 Settings 버튼까지, 교대로 15쌍 | bundle 중앙값 1527 ms, debug 1520 ms(첫
launch 제외 14쌍) |

main의 desktop e2e lane은 같은 spec이 kit 없이 통과해 왔다(#686, #698의 PR run). 이
PR부터 이 class가 PR에서 실패로 잡힌다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: browser CDP: the native guard cancels a pending preattach file load and remains restricted after disconnect

1 participant