Skip to content

fix(ego-linux-host): reject pending requests when a connection is closed - #66

Open
zhuran24 wants to merge 1 commit into
opencue:mainfrom
zhuran24:fix/linux-host-close-rejects-pending
Open

zhuran24 wants to merge 1 commit into
opencue:mainfrom
zhuran24:fix/linux-host-close-rejects-pending

Conversation

@zhuran24

Copy link
Copy Markdown

Summary

HostConnection.close() left requests that were still waiting for a reply pending forever. It now rejects them with EGO_TASK_HOST_DISCONNECTED, the error a dropped socket already produces.

Related issue

None: issues are disabled on this repository.

Changes

close() cleared the pending map without settling the promises in it. The socket's close handler, which normally rejects them, returns early when the connection is already marked closed. A caller awaiting conn.request(...) when close() ran therefore never resolved or rejected.

close() now calls the existing failAll() with EGO_TASK_HOST_DISCONNECTED before destroying the socket. A second close() stays a no-op, and requests made after close() still reject as before.

To reproduce, connect to a socket server that accepts requests and never replies, send two requests, and call close(): on main, both promises stay pending.

Verification

Run from package/ego-linux-host.

Check main This branch
npm test (build, typecheck, tests) 129 passed, 3 skipped 130 passed, 3 skipped
New test against main's source fails: unfinished requests remained pending after close passes

The 3 skipped tests need a real browser environment and skip themselves on both.

Impact

No public API change. A caller whose request is cut short by close() now gets an EGO_TASK_HOST_DISCONNECTED error instead of waiting forever.

🤖 Generated with Claude Code

HostConnection.close() cleared the pending-request map without settling
the promises in it, and the socket's close handler then returned early
because the connection was already marked closed. A request still waiting
for its reply when close() was called never resolved or rejected, so its
caller waited forever. close() now rejects them with
EGO_TASK_HOST_DISCONNECTED, the error a dropped socket already produces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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