Skip to content

EW-10529 Route OutgoingFactory subrequests through getSubrequestNoChecks#6513

Open
harrishancock wants to merge 1 commit intomainfrom
harris/EW-10529-subrequest-memory-adjustment
Open

EW-10529 Route OutgoingFactory subrequests through getSubrequestNoChecks#6513
harrishancock wants to merge 1 commit intomainfrom
harris/EW-10529-subrequest-memory-adjustment

Conversation

@harrishancock
Copy link
Copy Markdown
Collaborator

TcpPortOutgoingFactory (containers) and StreamOutgoingFactory (TCP sockets) constructed WorkerInterface instances directly, bypassing getSubrequestNoChecks() and missing the external memory adjustment that pressures V8's GC. Route them through getSubrequestNoChecks() so they get the same accounting as other subrequest types.

Also add comments on OutgoingFactory, CrossContextOutgoingFactory, getSubrequestNoChecks(), getCapnpChannel(), and getClientWithTracing() documenting the contract: implementations that create HTTP connections should route through getSubrequestNoChecks() internally.

Assisted-by: Claude

@harrishancock harrishancock requested review from a team as code owners April 7, 2026 16:59
@harrishancock harrishancock requested a review from danlapid April 7, 2026 17:00
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 7, 2026

I now have a complete understanding of the change. Let me summarize my analysis:

What the PR does:

  1. Routes TcpPortOutgoingFactory::newSingleUseClient() (containers) and StreamOutgoingFactory::newSingleUseClient() (TCP sockets) through getSubrequestNoChecks() to get the external memory adjustment (8KB pressure on V8 GC).
  2. Adds documentation comments on OutgoingFactory, CrossContextOutgoingFactory, getSubrequestNoChecks(), and getCapnpChannel() explaining the contract.

Analysis:

The change is well-structured. The two factories that were previously constructing WorkerInterface instances directly now route through getSubrequestNoChecks(), which provides:

  • External memory adjustment (8KB) to pressure V8's GC
  • Tracing support (though neither caller passes operationName)
  • Optional metrics wrapping (both pass wrapMetrics = false)

Both use {.inHouse = false, .wrapMetrics = false} which is reasonable — containers and TCP sockets are external and don't need metrics wrapping at this level.

The callback parameters (tracing, channelFactory) are unused in both cases since these factories don't need tracing or channel factory access — they construct their own WorkerInterface directly. This is fine; the important part is the wrapping that getSubrequestNoChecks applies after the callback returns.

The actor factories (GlobalActorOutgoingFactory, LocalActorOutgoingFactory, ReplicaActorOutgoingFactory, FacetOutgoingFactory) already route through getSubrequest() which calls getSubrequestNoChecks() internally — so they're already covered.

The documentation comments are accurate and helpful, clearly stating the contract.

I don't see any actionable issues — the change is correct, well-scoped, and the documentation additions are valuable.

LGTM

github run

@jasnell
Copy link
Copy Markdown
Collaborator

jasnell commented Apr 7, 2026

PR will need to be rebased on main for CI to run successfully.

TcpPortOutgoingFactory (containers) and StreamOutgoingFactory (TCP
sockets) constructed WorkerInterface instances directly, bypassing
getSubrequestNoChecks() and missing the external memory adjustment
that pressures V8's GC. Route them through getSubrequestNoChecks() so
they get the same accounting as other subrequest types.

Also add comments on OutgoingFactory, CrossContextOutgoingFactory,
getSubrequestNoChecks(), getCapnpChannel(), and getClientWithTracing()
documenting the contract: implementations that create HTTP connections
should route through getSubrequestNoChecks() internally.

Assisted-by: Claude
@harrishancock harrishancock force-pushed the harris/EW-10529-subrequest-memory-adjustment branch from 0f2add6 to d679549 Compare April 10, 2026 17:20
@harrishancock
Copy link
Copy Markdown
Collaborator Author

Rebased on main.

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