Skip to content

enclave-server: set a write deadline and check deadline errors on vsock conns - #34

Merged
nickpell merged 1 commit into
mainfrom
nick/openarbiter-enclave-write-deadline
Sep 24, 2026
Merged

nickpell merged 1 commit into
mainfrom
nick/openarbiter-enclave-write-deadline

Conversation

@nickpell

@nickpell nickpell commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • handleConnection in cmd/enclave-server/main.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 enclave: set a write deadline and check deadline errors on vsock conns openauction#74; the two PRs are independent and can merge in either order.
  • cmd/enclave-server/main_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

  • Tests pass (mise run //:test, including the new TestHandleConnection_* tests)
  • Lint passes (mise run //:lint, mise run //:tidy)
  • Diff contains no unintended changes

Post-deploy/apply verification

  • EIF build for the merge commit succeeds and its PCR measurements commit lands on main (Build EIF run 36014966655; PCR commit bfd8058)
  • New enclave image rolled out and ping health checks pass

🤖 Generated with Claude Code

…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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@nickpell
nickpell merged commit 95ad625 into main Sep 24, 2026
4 checks passed
@nickpell
nickpell deleted the nick/openarbiter-enclave-write-deadline branch September 24, 2026 14:36
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.

2 participants