Skip to content

Remove a desktop fixture's root after Herdr stops on Windows - #572

Merged
yansfil merged 1 commit into
mainfrom
ci/desktop-add-project-cleanup
Oct 6, 2026
Merged

yansfil merged 1 commit into
mainfrom
ci/desktop-add-project-cleanup

Conversation

@yansfil

@yansfil yansfil commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #566, #412

Summary

Windows desktop @platform test add-project.spec.ts:37 failed in its cleanup, not in its body: removing the fixture root hit EBUSY on the registered project folder home\projects\alpha.
The desktop fixture removed the root right after stopping hided, while the Herdr server it shares was still running, and a Herdr pane keeps its working folder locked on Windows until the server's processes are gone.
The root is now removed by the Herdr fixture's stop on Windows, the same order web/e2e/hided-fixture.ts already uses (herdr.afterStop); other systems remove it at once as before.

Review

  • 판단해 주세요: 없음. 판단할 제품 결정은 없고 fixture 정리 순서만 바뀐다.
  • 조심해서 볼 파일: desktop/e2e/fixture.ts cleanup - Windows에서만 root 삭제를 herdr.afterStop으로 미룬다. 삭제 실패는 이제 herdr.stop()에서 던져진다.
  • 질문: hide stop은 멈추는 데 쓰지 않는 HIDE_OPEN_COMMAND 같은 키까지 모두 검증하고(hided/src/cli.rs:285의 env::load()) 틀리면 거부한다. 이번 실패에서는 부분 삭제가 오프너 파일을 지운 뒤의 재시도가 이 거부를 보여 줬을 뿐 원인은 아니다. 그래도 "잘못된 무관한 키 때문에 떠 있는 데몬을 멈출 수 없다"는 점은 제품 쪽 별도 질문이다. 이 PR에서는 바꾸지 않았다. 이슈로 올릴까?

Evidence

  • 확인한 것:
    • 진단 dispatch 1회 (nightly 37352097532, Windows): 오프너 root\bin\hide-open.exe는 isolate, launch, 프로젝트 등록, app.close(), 첫 hide stop 직전과 직후(status 0)까지 모두 존재했다(stat ok, 107520 bytes).
    • 같은 run의 두 번째 정리 시도에서야 ENOENT가 되고 hide stop이 HIDE_OPEN_COMMAND: invalid(status 2)로 거부됐다. 첫 hide stop은 성공했고, 그 뒤 fs.rmSync(root)가 bin을 지운 다음 home\projects\alpha에서 EBUSY로 멈췄다. 이전 run(37349223208)의 invalid는 이 부분 삭제의 결과였다.
    • 같은 EBUSY ...\home\projects\alpha가 nightly 분류의 G1c(web s2:499, cmdk:396, home:82)에도 있고, hided-fixture.ts에 같은 원인(pane의 작업 폴더가 Herdr 서버 종료 전까지 잠김)과 afterStop 순서가 이미 주석으로 있다.
    • 로컬(macOS): fixture-cleanup.unit.ts 6개 통과(새 test 포함), desktop tsc, eslint. 새 unit test는 macOS의 즉시 삭제 분기만 돈다.
  • 확인하지 못한 것:
    • 이전 verify의 macOS desktop e2e 빨강은 browser.spec.ts:753(area cycle native, @needs-focus)가 retry까지 실패한 것으로, 열린 flaky #511이다. 같은 시간대 main run 37352905893, 37348869063도 같은 job이 같은 test로 실패했고 이후 main은 녹색이다. 이 PR이 건드린 파일과 무관하다. origin/main(2277e7a) 위로 다시 쌓아 새 verify를 돌린다.
    • alpha를 잡고 있는 것이 Herdr pane이라는 점은 직접 보지 못했다. 위 두 근거(기록된 기전, 같은 폴더 이름의 web 실패)와 "첫 stop 성공 뒤에도 alpha만 잠김"으로 추정한다.
    • 이 수정은 Windows CI에서 돌려 보지 않았다(dispatch 한도 소진). 이 PR의 windows e2e가 desktop @platform을 돌리지 않으므로, 확인은 이 PR 머지 뒤 nightly 한 번이다.
    • Windows unit test 분기(root가 afterStop 호출 전까지 남음)는 로컬에서 돌리지 못했다.

@yansfil
yansfil force-pushed the ci/desktop-os-scope branch from 95ad646 to 77f2695 Compare October 6, 2026 00:39
@yansfil
yansfil force-pushed the ci/desktop-add-project-cleanup branch from e3f2d26 to a289055 Compare October 6, 2026 00:40
@yansfil
yansfil force-pushed the ci/desktop-os-scope branch from 77f2695 to f5bc2cf Compare October 6, 2026 02:15
@yansfil
yansfil force-pushed the ci/desktop-add-project-cleanup branch from a289055 to 0655bce Compare October 6, 2026 02:15
@yansfil
yansfil force-pushed the ci/desktop-os-scope branch from f5bc2cf to 7a1083c Compare October 6, 2026 02:40
@yansfil
yansfil force-pushed the ci/desktop-add-project-cleanup branch from 0655bce to 86a36aa Compare October 6, 2026 02:40
yansfil added a commit that referenced this pull request Oct 6, 2026
…#566)

Related: #412

## Summary

nightly의 Linux/Windows desktop e2e는 10-04에 들어온 뒤 한 번도 통과하지 못했다. 앞쪽 test가
90초씩 걸려 20분 상한을 다 썼고, 그 원인은 test가 아니라 제품 결함이었다.
`hide connect`가 띄우는 hided와 그 자식 Herdr가 부모(Electron)가 받은 디버깅 pipe(fd 3,
4)를 물려받아, 앱이 이미 종료돼도 Playwright의 `app.close()`가 pipe가 닫히길 기다렸다. 실제 사용자도
앱을 띄운 터미널이나 감독 프로세스가 pipe 닫힘을 기다리면 같은 모양으로 멈춘다.
이 PR은 (1) detach가 부모의 추가 fd/handle을 데몬에 넘기지 않게 고치고, (2) desktop e2e 중 OS
차이를 확인하는 6개에 `@platform`을 붙여 Linux/Windows nightly는 그것만 돌리게 하고, (3)
nightly web은 macOS와 Windows의 `@platform`만, desktop은 macOS 전체와
Linux/Windows의 `@platform`만 돌린다(Linux web은 PR과 `verify`가 전체를 돌린다).
#561(PR 검사 B+C)이 이 PR 머지 뒤 `desktop/src/main` 변경 시 Linux/Windows desktop
`@platform`을 PR에서 돌릴 예정이다.

## Review

commit 3개이고 각각 볼 곳이 다르다.

**1. `Start a detached daemon without the descriptors its parent was
lent` (제품 수정, 가장 중요)**
- **판단해 주세요**: Windows 방식이 문서화된 방법이 아니다. `detach`가 부모의 handle 값
4..65536을 훑어 INHERIT를 끈다. 한계 두 가지: (1) 상한 밖 handle은 못 잡는다 (2) 부모 프로세스의
handle 플래그를 바꾼다. 호출자가 수명이 짧은 `hide connect`가 daemon을 띄우는
`hided/src/spawn.rs`의 `spawn_owned` 하나뿐이라 허용했고, 다른 thread가 동시에 child를
띄우는 process는 부르면 안 된다는 전제를 `detach` 문서에 적었다(그 child가 상속할 handle을 지울 수
있음). 문서화된 방법인 `PROC_THREAD_ATTRIBUTE_HANDLE_LIST`는 std의 `raw_attribute`가
unstable이라 `CreateProcessW`를 직접 써야 해서 이번에는 하지 않았다.
- **조심해서 볼 파일**: `hide-platform/src/process.rs` `detach` (Unix
`pre_exec`, Windows 쓸기) - fork 뒤에는 POSIX가 안전하다고 적은 `fcntl`과 맨 시스템 호출
`syscall`만 쓰는지(`sysconf`는 목록에 없어 fork 전에 계산해 closure로 넘김), fd를 닫지 않고
close-on-exec로 표시한 이유(std의 exec 오류 pipe가 exec까지 살아 있어야 함), `sysconf`가
-1이면 상한까지 표시.
- **비용 검토**: Unix는 `close_range(CLOEXEC)` 한 번, 커널이 못 받으면 fd
3..상한(65,536)을 `fcntl`로 훑는다. macOS는 `close_range`가 없어 항상 후자다(데몬 시작 때 한
번, 상한은 `ulimit -n`과 65,536 중 작은 값).

**2. `Tag the desktop e2e tests that check what differs by system`**
- **판단해 주세요**: 고른 6개가 맞는가. 기준은 "그 OS에서 다르게 동작하는 것을 확인하는가"이고 통과 여부로 고르지
않았다. 나머지(⌘ chord 고정, 창/compositor, SSH, packaged app)는 macOS에서만 돈다.
- **조심해서 볼 파일**: `desktop/e2e/desktop.spec.ts` - attach는 chord를
`web/e2e/chords.ts`에서 읽고, lifetime은 마지막 창을 닫으면 macOS는 앱 유지, 그 밖에는 종료 뒤에도
hided 유지로 OS별 단언을 한다. `add-project.spec.ts`, `reveal-external.spec.ts`는
화면의 경로를 wire 표기(`toPage`, `docs/TESTING.md`의 규칙)로 비교한다.
- Linux에서만 드러난 결함 두 개도 같이 고쳤다: screenshot helper가 `screencapture`를 OS와
무관하게 실행했고, lifetime의 두 번째 Electron 직접 spawn에 Playwright가 첫 인스턴스에 주는
`--no-sandbox`가 없었다.

**3. `Run only the @platform tests on the desktop and web nightly where
they differ by system`**
- **조심해서 볼 파일**: `.github/workflows/nightly.yml` - web은 macOS와 Windows가
`@platform` 1 shard(Linux 전체 web은 `verify`가 돌려 nightly web job이 없다),
desktop은 macOS 전체와 Linux/Windows `@platform`. #574의 lane 규칙은 그대로다: macOS
OS 계약은 `hide-platform`/`hide-herdr-client` 변경 때 도는 별도 job이고 desktop e2e는
`os-contract`를 따라오지 않으며, nightly에는 `os-contract` job도 없다(`verify`가 세
leg를 돈다). `scripts/tests/test_ci_plan.py`에 nightly 범위 test를 더했다.
- 문서: `CONTRIBUTING.md`, `docs/TESTING.md`,
`docs/PERFORMANCE_TESTING.md`, `pr.yml` 주석(동작 변경 없음).

## Evidence

- **확인한 것**:
- 원인: 진단 dispatch 3회(Linux, 이미 제거한 temporary 코드). Electron은
`app.close()` 50ms 안에 exit 0, stdout/stderr destroyed인데 `close`(stdio
종료)는 hided를 죽인 1.5초 뒤에야 도착했고, hided의 fd 3, 4가 앱의 것과 같은 inode였다.
- Linux 수정 확인 (nightly 37344130136): desktop `@platform` job 20분 상한
timeout(수정 전 37312210782) -> 3분 47초, 6/6 통과, 합 44.8초(add-project 12.7s,
attach 2.5s, lifetime 4.8s, 없는 CLI 2.1s, reattach 9.2s, reveal 3.1s).
web `@platform` 1/1 통과(6.5분, 이 job은 3번 commit이 뺐다). 이 run은 수정 직후
커밋(`ef60ac4b`)이고, 이후 바뀐 것은 lifetime의 non-darwin `closing` 처리 등 test 쪽이라
Linux에서는 그 최종 상태를 다시 돌리지 않았다.
- Windows 수정 확인 (nightly 37349223208, 최종 HEAD `31657880`): desktop job
26분(수정 전 37315772488) -> 7.5분(test 1.3분), 5/6 통과, `Worker teardown
timeout` 소멸. attach 9.1s, lifetime 4.0s, 없는 CLI 4.5s, reattach 8.5s,
reveal 3.9s. web `@platform` 1/1 통과(12.2분).
- 로컬(macOS): desktop `@platform` 6/6(57.7s), `hide-platform` process 계약
34 passed(새 test는 수정 전에 macOS에서 실패 확인), `hided` connect_stop/handshake,
clippy, fmt, Windows/Linux target `cargo check --all-targets`, desktop
typecheck/lint, `scripts/tests` 134 OK(첫 실행에서 에러 1건, 어떤 test인지 못 잡았고
재실행은 통과, 부하 때문으로 보임).
- **확인하지 못한 것**:
- 이전 verify의 macOS desktop e2e 빨강은 `browser.spec.ts:753`(area cycle
native, `@needs-focus`)가 retry까지 실패한 것으로, 열린 flaky #511이다. 같은 시간대 main
run 37352905893, 37348869063도 같은 job이 같은 test로 실패했고 이후 main은 녹색이다. 이 PR이
건드린 파일과 무관하다. origin/main(afe83b1, #574 포함) 위로 다시 쌓아 새 verify를 돌린다.
- 빨강 1건: Windows `add-project.spec.ts:37` (37349223208). test 본문은 통과하고
정리에서 실패한다. 진단 run(37352097532)으로 확인: 첫 `hide stop`은 성공하고, 이어지는
`fs.rmSync(root)`가 `home\projects\alpha`에서 `EBUSY`로 멈추기 전에
`bin\hide-open.exe`를 지운다. 재시도의 `hide stop`이 보여 주는 `HIDE_OPEN_COMMAND:
invalid`는 그 부분 삭제의 결과다. 잠금은 Herdr pane의 작업 폴더로 추정하고(직접 확인하지 못함), 수정은
#572(이 PR 위에 쌓음)가 한다.
- 새 계약 test
`a_detached_child_holds_none_of_its_parents_extra_descriptors`는 로컬에서
macOS만 돌렸다. Linux/Windows는 이 PR의 `os contract`와 `windows check`가 처음 돌린다.
수정 전 Linux/Windows에서의 실패는 직접 보지 않았고, 수정 전 macOS 실패와 Linux 진단 로그로 갈음했다.
  - macOS desktop 전체 suite와 Linux 전체 web suite는 이 PR의 verify가 돈다.
- nightly 전체는 이 branch에서 lane별로만 돌렸다(`os contract`, `package`는
`all`에서만).

<details><summary>추가 증거: Windows web 전체(바꾸지 않음) 실패 목록</summary>

nightly Windows web full(37315772488)의 실패 test 15건을 "Windows 차이를 확인하는가"로
나눴다(표는 로컬 run 기록, 저장소 밖). 확인하는 것은 checkout-pr:99, home:82, s8:83 세
개뿐이고(경로 표기와 link), 나머지 12건은 fixture가 따라가지 못한 flow test다. 운영자 결정으로
nightly Windows web은 `@platform`만 돌게 되어 이 PR에서 바뀐다. 세 test의 태그와 수정은 별도
세션이 맡는다.

</details>
Base automatically changed from ci/desktop-os-scope to main October 6, 2026 03:07
@yansfil
yansfil force-pushed the ci/desktop-add-project-cleanup branch 2 times, most recently from 41831e2 to bc585cf Compare October 6, 2026 03:17
@yansfil
yansfil force-pushed the ci/desktop-add-project-cleanup branch from bc585cf to dcf1025 Compare October 6, 2026 03:17
@yansfil
yansfil merged commit 26028ab into main Oct 6, 2026
13 checks passed
@yansfil
yansfil deleted the ci/desktop-add-project-cleanup branch October 6, 2026 03:53
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.

1 participant