Skip to content

Hold a dropped file for the pane's first terminal session instead of losing it - #740

Merged
yansfil merged 2 commits into
mainfrom
fix/flaky-735-drop
Oct 7, 2026
Merged

yansfil merged 2 commits into
mainfrom
fix/flaky-735-drop

Conversation

@yansfil

@yansfil yansfil commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Closes #735
Related: #714, #716

Summary

  • 실패: Linux web e2e a dropped file reaches the terminal as an attachment가 15 s 동안 pane 입력을 빈 문자열로 보았다(PR #733의 run, #716이 든 merge commit).
  • 원인: web은 layout이 오면 pane을 그리고, 그 pane의 terminal session은 그 뒤에 붙는다. drop의 commit이 그 session보다 먼저 core에 닿았다.
    • commit 22.312, pane의 첫 session 요청 22.315, ready 22.316. core는 session 없는 pane을 "unavailable"로 실패시켰고 다음 tick에 retired로 치웠다.
    • web은 core의 첨부 실패를 그리지 않아 drop이 조용히 사라졌다.
  • 제품 영향: 새 tab이나 split 직후, hided 재연결 직후의 pane에 파일을 떨구거나 이미지를 붙여 넣으면 아무것도 붙지 않았다. 그 사이 친 입력도 버려졌다.
  • 수정: session이 아직 없는 로컬 pane이면 첨부가 그 pane의 session을 기다렸다가, paste와 그 뒤에 친 입력을 붙는 순간 순서대로 쓴다.
    • 상한은 hided가 commit한 파일을 지우지 않는 COMMIT_GRACE(60 s)다. hide_node_link::attachments로 옮겨 hided와 core가 같이 읽는다.
    • 기한은 기존 coordinator tick(tick_async_operations(now), 250 ms)이 event 없이 확인한다. 넘으면 지금과 같은 unavailable 실패로 끝나고 terminal.attachment.terminal_wait_expired 진단을 남긴다.

Review

  • 판단해 주세요: 기다림의 상한을 새 상수 대신 COMMIT_GRACE로 잡았다. paste는 staged 파일 경로라, 그보다 늦게 쓰면 지워졌을 수 있는 경로를 붙인다.
    • 기한은 core의 admission부터 잰다. hided의 commit보다 몇 ms 늦게 시작한다.
  • 판단해 주세요: 기다리는 것은 그 pane의 첫 session(또는 drop 때 이미 시작 중이던 session) 하나다. 그 session이 다시 붙거나 pane이 사라지면 지금처럼 retired.
  • 조심해서 볼 파일: herdr-core/src/runtime/attachments.rs - runtime mutex 안의 상태 전이와 failure path. 쓰기는 session.write_bytes(channel send)뿐이라 lock 안 I/O가 없다.
    • 기다리는 동안의 입력은 기존 64 KiB hold를 그대로 쓴다.
  • 조심해서 볼 파일: herdr-core/src/runtime/terminal.rs - session 시작에서 첫 generation을 채택하고, session ready에서 기다리던 첨부를 다시 본다.
  • 비용 검토: 첨부가 있을 때만 tick마다 field 비교 몇 개, session ready마다 reconcile_attachment_target 한 번(첨부가 없으면 바로 반환). 새 timer나 thread는 없다.
  • 남은 것: core의 첨부 실패가 화면에 보이지 않는 것은 무엇을 보일지 정할 제품 결정이라 이 PR 밖이다. 따로 올린다.

Evidence

  • 확인한 것:
    • 원인(로그만, build 없이): CI run 37593508403 시도 1의 wire 기록과 hided 진단에서 위 시각을 읽었다.
      • session의 generation 2는 그 pane의 첫 것이다(1은 다른 pane). 통과한 재시도는 session ready(…149.783) 뒤에 commit(…149.840)이 왔다.
    • before: 새 test a_drop_before_the_panes_first_session_is_written_to_that_session을 수정 전 core에서 돌리면 drop 직후 phase가 failed라 실패한다.
    • after(macOS 로컬): 새 test 3개를 포함한 runtime::attachments 10개 통과.
      • 새 test는 session 전 drop이 그 session에 순서대로 써짐(파일 먼저와 session 먼저 두 순서), 시간 주입 tick(deadline-1은 대기, deadline에 실패와 진단, 늦은 session에 0 byte, 다음 drop 허용), 기다리는 중 pane 사라짐과 재연결의 retired다.
    • herdr-core lib 1,649개, hide-node-link 7개, hided lib 263개와 integration 65개 통과. fmt와 policy 구조 검사 통과.
  • 확인하지 못한 것:
    • clippy는 로컬 디스크가 부족해(build 규칙 8 GiB 미만) 돌리지 않았고 CI rust lane에 맡긴다.
    • 로컬 test는 base ae20a1c5에서 돌렸다. 그 뒤 main(c1c472e7, Herdr bump 등, 겹치는 코드 없음)으로 rebase했고, 디스크 때문에 다시 build하지 않아 CI에 맡긴다.
    • 고친 경합을 web e2e에서 다시 일으켜 보지는 않았다. core 단위 test가 같은 순서(session 전 commit)를 결정적으로 밟는다.
    • 첫 전체 실행에서 hided a_reconnect_resumes_from_the_client_cursor가 1회 실패했다("a delta at the current revision has no rest"). 단독 5회와 전체 재실행에서 통과했고 첨부를 쓰지 않는 test다.

@yansfil
yansfil merged commit 6f11b51 into main Oct 7, 2026
20 checks passed
@yansfil
yansfil deleted the fix/flaky-735-drop branch October 7, 2026 11:13
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: a dropped file reaches the terminal as an attachment

1 participant