[PR #1866] [MERGED] fix(hopper): wait for late bridges during cleanup #4862

Closed
opened 2026-10-31 00:56:09 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1866
Author: @morluto
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @morluto

Base: main ← Head: codex/fix-hopper-late-cleanup


📝 Commits (1)

  • f821883 fix(hopper): wait for late bridges during cleanup

📊 Changes

8 files changed (+323 additions, -205 deletions)

View changed files

📝 src/hopper/HopperClient.ts (+25 -5)
📝 tests/acceptance/providers/hopperStartupRecovery.test.ts (+218 -189)
📝 tests/boundary/cli/hopperLaunchFailureCli.test.ts (+2 -1)
📝 tests/boundary/providers/hopper/hopperClient.cleanup.test.ts (+1 -1)
📝 tests/boundary/providers/hopper/hopperClient.handshakeRecovery.test.ts (+71 -3)
📝 tests/boundary/providers/hopper/hopperClient.health.test.ts (+1 -1)
📝 tests/boundary/providers/hopper/hopperClient.helperFailure.test.ts (+4 -4)
📝 tests/boundary/providers/hopper/hopperClient.startupFailures.test.ts (+1 -1)

📄 Description

Addresses the remaining review comment from #1817, which merged while this fix was being prepared.

close_binary previously made one socket connection attempt after a timed-out Hopper handoff. A missing or refused endpoint returned immediately, even when the matching bridge appeared milliseconds later. Retry only ENOENT and ECONNREFUSED within the existing 30-second cleanup deadline, sharing that deadline with the health handshake. Other connection failures, rejected credentials, and mismatched run identities retain ownership without requesting document shutdown.

Preserve the configured startup timeout and launcher diagnostics when the health request's timer fires before the startup timer. Extend the regression coverage to publish the socket after close begins, including an actual refused Unix socket and the compiled stdio MCP workflow. Allow the failure tests to exercise the full cleanup window, and await the SDK child-close event before recovering a retained target lease.

Validation:

  • Combined focused config/Hopper/CLI/MCP coverage: 186 passing cases across 25 files, with two platform skips, including targeted reruns after test budget and teardown corrections.
  • After moving onto current main: handshake, deadline, and protocol suites passed all 28 cases.
  • npm run check and the pre-push check passed.
  • Native Hopper 6.6 probe on macOS 26.3 arm64: interrupt a valid session through a local socket relay, start explicit close while its endpoint is absent, then republish the endpoint 150 ms later. REA authenticated the exact run, confirmed document closure, and removed the runtime. The delayed endpoint was controlled by the probe; this does not establish the reporter's macOS 27 GUI-crash behavior.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1866 **Author:** [@morluto](https://github.com/morluto) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/fix-hopper-late-cleanup` --- ### 📝 Commits (1) - [`f821883`](https://github.com/morluto/rea/commit/f82188310a11ca6ab4666623c4f560c32968b222) fix(hopper): wait for late bridges during cleanup ### 📊 Changes **8 files changed** (+323 additions, -205 deletions) <details> <summary>View changed files</summary> 📝 `src/hopper/HopperClient.ts` (+25 -5) 📝 `tests/acceptance/providers/hopperStartupRecovery.test.ts` (+218 -189) 📝 `tests/boundary/cli/hopperLaunchFailureCli.test.ts` (+2 -1) 📝 `tests/boundary/providers/hopper/hopperClient.cleanup.test.ts` (+1 -1) 📝 `tests/boundary/providers/hopper/hopperClient.handshakeRecovery.test.ts` (+71 -3) 📝 `tests/boundary/providers/hopper/hopperClient.health.test.ts` (+1 -1) 📝 `tests/boundary/providers/hopper/hopperClient.helperFailure.test.ts` (+4 -4) 📝 `tests/boundary/providers/hopper/hopperClient.startupFailures.test.ts` (+1 -1) </details> ### 📄 Description Addresses the [remaining review comment](https://github.com/morluto/rea/pull/1817#discussion_r4241701640) from #1817, which merged while this fix was being prepared. `close_binary` previously made one socket connection attempt after a timed-out Hopper handoff. A missing or refused endpoint returned immediately, even when the matching bridge appeared milliseconds later. Retry only `ENOENT` and `ECONNREFUSED` within the existing 30-second cleanup deadline, sharing that deadline with the health handshake. Other connection failures, rejected credentials, and mismatched run identities retain ownership without requesting document shutdown. Preserve the configured startup timeout and launcher diagnostics when the health request's timer fires before the startup timer. Extend the regression coverage to publish the socket after close begins, including an actual refused Unix socket and the compiled stdio MCP workflow. Allow the failure tests to exercise the full cleanup window, and await the SDK child-close event before recovering a retained target lease. Validation: - Combined focused config/Hopper/CLI/MCP coverage: 186 passing cases across 25 files, with two platform skips, including targeted reruns after test budget and teardown corrections. - After moving onto current main: handshake, deadline, and protocol suites passed all 28 cases. - `npm run check` and the pre-push check passed. - Native Hopper 6.6 probe on macOS 26.3 arm64: interrupt a valid session through a local socket relay, start explicit close while its endpoint is absent, then republish the endpoint 150 ms later. REA authenticated the exact run, confirmed document closure, and removed the runtime. The delayed endpoint was controlled by the probe; this does not establish the reporter's macOS 27 GUI-crash behavior. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:56:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4862
No description provided.