Commit 216895f
test: dial agent socket instead of stat'ing it in waitForSocket (#261)
Tests that stop and immediately restart the agent — e.g.
TestPassphraseSetViaKex doing `y.stop(t); y.runAgent(t);
verifyPassphraseLockedThenUnlock(...)` — can race on CI: `stop()`
returns when the shutdown RPC is acked, which may be before the old
agent's socket file is unlinked. The new agent's goroutine then races
against the next CLI invocation. `os.Stat(sock) == nil` succeeds
against the stale file before the new listener exists, so
waitForSocket returns "ready" too early and the next dial fails with
"failed to connect to agent at path ...".
Replace the stat with `net.DialTimeout("unix", sock, 50*ms)` so we
only return once a connection actually completes. A stale unlinked
file no longer fools us; if no one's listening the dial fails fast
with ECONNREFUSED and we keep polling.
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>1 parent 63e82eb commit 216895f
1 file changed
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
463 | 464 | | |
464 | 465 | | |
465 | 466 | | |
466 | | - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
467 | 471 | | |
468 | 472 | | |
469 | | - | |
| 473 | + | |
470 | 474 | | |
| 475 | + | |
471 | 476 | | |
472 | 477 | | |
473 | 478 | | |
474 | 479 | | |
475 | 480 | | |
476 | 481 | | |
477 | 482 | | |
478 | | - | |
| 483 | + | |
479 | 484 | | |
480 | 485 | | |
481 | 486 | | |
| |||
0 commit comments