Skip to content

fix(daemon): a relay lets go of its target Request once it answers - #1533

Merged
V3RON merged 2 commits into
mainfrom
bug/1409
Nov 11, 2026
Merged

V3RON merged 2 commits into
mainfrom
bug/1409

Conversation

@V3RON

@V3RON V3RON commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1409

Status

Implement: done (1/1 green) Review: round 1, 0 blocking Hardware: n/a Gate: parked, CI install step red twice (runner DNS)
Next: rerun CI when runners resolve the Ubuntu mirror, then the gate

Done when

  • A worker's relay lets every Request it handed a target be collected once the relay has answered (test: src/daemon/relay.test.ts, "lets every Request it handed a target be collected once the relay has answered") — the test fails without the fix and passes 6/6 with it (audit probe and code review)

Assumptions

none

Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 0 blocking, 0 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 1 notes.
Rounds: 1. Tokens: 2.2M.
Runs: 6. Cost USD: 0.9475. Agent seconds: 1580.
Assessment: complete

Written by an agent.

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

After #run completes, RelayConnection.#admitted clears active.request in a finally block. A new test sends bodyless GET and body-bearing PUT requests through the relay. It then runs garbage collection and checks that both request objects are no longer reachable through their weak references.

Severity of issue fixed: High

Merge Risk: Minimal · up to cf6b9

The change releases request objects once the relay has answered, which reduces memory retention in the worker daemon. No concrete merge-blocking risk was found in the changed code.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: releasing target Request objects after the relay answers.
Linked Issues check Passed Issue #1409 identifies request retention in relay paths as one possible source of worker memory growth. The PR clears active.request in RelayConnection.#admitted inside finally, so cleanup also …
Out of Scope Changes check Passed The changes are limited to src/daemon/relay.ts and src/daemon/relay.test.ts. The source change releases the retained Request that the test verifies. The garbage-collection helper and the two req…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Description check Passed The description directly relates to the changes. It identifies the Request-retention fix, the relay garbage-collection test, and the linked issue.
Full details: Linked Issues check

Explanation

Issue #1409 identifies request retention in relay paths as one possible source of worker memory growth. The PR clears active.request in RelayConnection.#admitted inside finally, so cleanup also occurs on errors and early returns. The added relay.test.ts test covers a bodyless GET and a body-bearing PUT and verifies that both handed-off Request objects become collectible after the relay answers. The PR does not claim to implement unrelated issue suggestions such as response streaming, device pruning, heap diagnostics, or lease reattachment.

Full details: Out of Scope Changes check

Explanation

The changes are limited to src/daemon/relay.ts and src/daemon/relay.test.ts. The source change releases the retained Request that the test verifies. The garbage-collection helper and the two request cases provide automated regression coverage for the linked issue objective. No unrelated behavior or files are changed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 345efc71-6fa2-444b-98db-abea616734e3
Commits

Reviewing files that changed from the base of the PR and between 84c85b1 and cf6b90f.

Files selected for processing: 2

  • src/daemon/relay.test.ts
  • src/daemon/relay.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@V3RON

V3RON commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Review ledger

Round 1: cf6b90f

Runs: 6. Cost USD: 0.9475. Agent seconds: 1580.
Tokens input 72, output 19121, cache read 858688, cache write 194226.
- build implementer: claude-sonnet-5-5 309 s $0.0724
- audit implementer: claude-sonnet-5-5 18 s $0.07
- review 1 reviewer: claude-sonnet-5-5 1135 s $0.3013
- review 1 code both: claude-opus-5-5 83 s $0.3695
- review 1 claims: claude-sonnet-5-5 21 s $0.0734
- review 1 spec: claude-sonnet-5-5 14 s $0.0609
Finding outcomes: {"nonblocking":1}. Classes: {"comment imprecise: listener closes over active":1}.
{"findings":[{"id":"R1","role":"claims","class":"comment imprecise: listener closes over active","outcome":"nonblocking","path":"src/daemon/relay.ts","round":"1"}]}

Written by an agent.

@V3RON

V3RON commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

Not blocking, not verified. Each is one reviewer's claim.

  • claims: src/daemon/relay.ts:159 the comment says the abort listener closes over active, but the listener at :153 names only channel; it holds in effect because V8 closures in that scope share one context.

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review November 11, 2026 16:16
@V3RON
V3RON merged commit 5ccccba into main Nov 11, 2026
100 of 109 checks passed
@V3RON
V3RON deleted the bug/1409 branch November 11, 2026 22:40
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.

Worker daemon aborts on a V8 out-of-memory error after hours of agent-device e2e traffic, ending every lease

1 participant