enclave-server: set a write deadline and check deadline errors on vsock conns - #34
Merged
Merged
Conversation
…ck conns A peer that stops reading the response held its worker slot until the connection closed. The response write now has a deadline, and a failure to set either deadline closes the connection instead of serving it unbounded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
5 tasks
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The deadline handling is correct and the added tests cover the key failure scenarios.
Review effort: Balanced
Findings: None
What changed in this PR
Adds deadline enforcement to prevent stalled vsock clients from exhausting enclave server workers.
Changes:
- Enforces and validates read and write deadlines.
- Closes connections when deadline setup fails.
- Tests stalled writes and read-deadline failures.
| File | Description |
|---|---|
cmd/enclave-server/main.go |
Adds checked read/write deadlines to connection handling. |
cmd/enclave-server/main_test.go |
Tests deadline-based release and failure handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
nickpell
added a commit
to cloudx-io/openauction
that referenced
this pull request
Sep 24, 2026
#74) ## Summary - `handleConnection` in `enclave/server.go` now sets a write deadline (30 s, starting once the request is handled) before encoding the response. Without it, a peer that stops reading holds its worker slot until the connection closes, and enough such peers exhaust the `ENCLAVE_MAX_WORKERS` pool. - A failure from `SetReadDeadline` or `SetWriteDeadline` is logged and the connection is closed, instead of being ignored and the connection served with no deadline. - Same change as cloudx-io/openarbiter#34; the two PRs are independent and can merge in either order. - `enclave/server_test.go` covers both paths: a peer that never reads the response releases the handler at the write deadline, and a failed `SetReadDeadline` closes the connection without reading. ## Pre-merge checklist - [x] Tests pass (`mise run //:test`, including the new `TestHandleConnection_*` tests) - [x] Lint passes (`mise run //:lint`, `mise run //:tidy`) - [x] Diff contains no unintended changes ## Post-deploy/apply verification - [ ] EIF build for the merge commit succeeds and its PCR measurements commit lands on `main` - [ ] New enclave image rolled out and ping health checks pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handleConnectionincmd/enclave-server/main.gonow sets a write deadline (30 s, starting once the request is handled) before encoding the response. Without it, a peer that stops reading holds its worker slot until the connection closes, and enough such peers exhaust theENCLAVE_MAX_WORKERSpool.SetReadDeadlineorSetWriteDeadlineis logged and the connection is closed, instead of being ignored and the connection served with no deadline.cmd/enclave-server/main_test.gocovers both paths: a peer that never reads the response releases the handler at the write deadline, and a failedSetReadDeadlinecloses the connection without reading.Pre-merge checklist
mise run //:test, including the newTestHandleConnection_*tests)mise run //:lint,mise run //:tidy)Post-deploy/apply verification
main(Build EIF run 36014966655; PCR commit bfd8058)🤖 Generated with Claude Code