detached b90b5f2

test(daemon): keep the real handshake budget in notifyClock (#302)

* test(daemon): keep the real handshake budget in notifyClock

notifyClock shortened every non-debounce timer to 5ms, including the 15s handshake deadline. On a slow runner the handshake expired before Welcome, so TestServeReturnsDespiteWedgedClientOnShutdown timed out. Only the detach-notify timer is shortened now.

* test(daemon): document notifyClock on its type
commit
b90b5f22cab856aecb1f7c9dcace04baece88e88
author
bnema · · 2026-09-29 18:31 UTC
committer
GitHub · · 2026-09-29 18:31 UTC
parent
46d259b
signature
GPG UnverifiedB5690EEEBB952194 The key is unknown
2 files · +11 -5
M internal/usecase/daemon/daemon_test.go +11 -2
@@ -661,14 +661,23 @@ func rowText(row []renderer.Cell) string {
661661 return string(runes)
662662 }
663663
664+// notifyClock stubs debounceInterval so schedulers park, and shortens
665+// detachNotifyTimeout to 5ms so a wedged client's Detached send is
666+// force-closed quickly. Every other budget, including the handshake deadline,
667+// runs at its real length. Timers are matched by duration value, so another
668+// budget equal to one of these constants gets the same treatment.
664669 type notifyClock struct{}
665670
666671 func (notifyClock) Now() time.Time { return time.Now() }
667672 func (notifyClock) NewTimer(d time.Duration) ports.Timer {
668- if d == debounceInterval {
673+ switch d {
674+ case debounceInterval:
669675 return stubTimer{}
676+ case detachNotifyTimeout:
677+ return realTimer{t: time.NewTimer(5 * time.Millisecond)}
678+ default:
679+ return realTimer{t: time.NewTimer(d)}
670680 }
671- return realTimer{t: time.NewTimer(5 * time.Millisecond)}
672681 }
673682
674683 type realTimer struct{ t *time.Timer }
@@ -661,14 +661,23 @@ func rowText(row []renderer.Cell) string {
661 return string(runes)661 return string(runes)
662 }662 }
663 663
664+// notifyClock stubs debounceInterval so schedulers park, and shortens
665+// detachNotifyTimeout to 5ms so a wedged client's Detached send is
666+// force-closed quickly. Every other budget, including the handshake deadline,
667+// runs at its real length. Timers are matched by duration value, so another
668+// budget equal to one of these constants gets the same treatment.
664 type notifyClock struct{}669 type notifyClock struct{}
665 670
666 func (notifyClock) Now() time.Time { return time.Now() }671 func (notifyClock) Now() time.Time { return time.Now() }
667 func (notifyClock) NewTimer(d time.Duration) ports.Timer {672 func (notifyClock) NewTimer(d time.Duration) ports.Timer {
668- if d == debounceInterval {673+ switch d {
674+ case debounceInterval:
669 return stubTimer{}675 return stubTimer{}
676+ case detachNotifyTimeout:
677+ return realTimer{t: time.NewTimer(5 * time.Millisecond)}
678+ default:
679+ return realTimer{t: time.NewTimer(d)}
670 }680 }
671- return realTimer{t: time.NewTimer(5 * time.Millisecond)}
672 }681 }
673 682
674 type realTimer struct{ t *time.Timer }683 type realTimer struct{ t *time.Timer }
M internal/usecase/daemon/session_test.go +0 -3
@@ -739,9 +739,6 @@ func TestHelloAfterExplicitShutdownIsRejected(t *testing.T) {
739739
740740 // --- wedged-client teardown ---------------------------------------------------
741741
742-// notifyClock drives the daemon with a stub debounce timer (schedulers park)
743-// but a short real timer for the detach-notify deadline, so a wedged client's
744-
745742 func TestServeReturnsDespiteWedgedClientOnShutdown(t *testing.T) {
746743 p, _ := newBlockingPTY(t) // Close unblocks the parked reader
747744
@@ -739,9 +739,6 @@ func TestHelloAfterExplicitShutdownIsRejected(t *testing.T) {
739 739
740 // --- wedged-client teardown ---------------------------------------------------740 // --- wedged-client teardown ---------------------------------------------------
741 741
742-// notifyClock drives the daemon with a stub debounce timer (schedulers park)
743-// but a short real timer for the detach-notify deadline, so a wedged client's
744-
745 func TestServeReturnsDespiteWedgedClientOnShutdown(t *testing.T) {742 func TestServeReturnsDespiteWedgedClientOnShutdown(t *testing.T) {
746 p, _ := newBlockingPTY(t) // Close unblocks the parked reader743 p, _ := newBlockingPTY(t) // Close unblocks the parked reader
747 744

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close