Let sendTraces() callers learn when the handler finishes by git-bruh · Pull Request #7855 · cloudflare/workerd · GitHub
Skip to content

Let sendTraces() callers learn when the handler finishes - #7855

Open
git-bruh wants to merge 1 commit into
mainfrom
pkhanna/trace-completion
Open

git-bruh wants to merge 1 commit into
mainfrom
pkhanna/trace-completion

Conversation

@git-bruh

Copy link
Copy Markdown
Member

EventDispatcher.sendTraces() returns as soon as the trace handler has been queued as a waitUntil task, before it has waited for its isolate lock or run. A caller therefore cannot tell how long the receiver keeps working on its traces.

Add an optional completion capability to sendTraces(), of a new empty TraceCompletion interface. The receiver attaches it to the handler's IncomingRequest, so it is released once that request drains: the handler and its background work finish, time out, or abort. TraceCustomEvent carries the capability, and forwards the same one when it sends the event over RPC. A receiver that predates the field ignores it, releasing it on arrival.

@git-bruh
git-bruh requested review from a team as code owners October 20, 2026 17:32
@clanky-the-clanker

clanky-the-clanker Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

@ask-bonk

ask-bonk Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Since last review: 0 resolved, 1 still open, 0 new.

Adds completion-capability plumbing for buffered and streaming tail RPC delivery.


Reviewed commit: 8c5586cc · github run

Comment thread src/workerd/api/trace.c++

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[WARNING] For an actor used as a dynamic tail target, another request can arrive while this tail handler or its event.waitUntil() work is still running. delivered() then fulfills this request's drainFulfiller, so drain() completes and destroys the attached capability, but actor waitUntil work remains in the shared IoContext task set for the newer request. The sender therefore observes completion before the handler's work has finished, contrary to the new completion contract. Keep the capability with per-event work that survives actor-request handoff, or reject actor tail targets until that lifetime can be represented.

@git-bruh
git-bruh force-pushed the pkhanna/trace-completion branch from 09c712d to cba0d22 Compare October 22, 2026 07:17
@git-bruh
git-bruh requested a review from a team as a code owner October 22, 2026 07:17
@git-bruh
git-bruh force-pushed the pkhanna/trace-completion branch from cba0d22 to ae67da6 Compare October 22, 2026 13:25
EventDispatcher.sendTraces() returns as soon as the trace handler
has been queued as a waitUntil task, before it has waited for its
isolate lock or run. tailStreamSession() returns once the session
completes, while the handler's waitUntil() work may continue. A
caller therefore cannot tell how long the receiver keeps working on
its traces.

Add an optional `completion` capability to both calls, of a new
empty TraceCompletion interface. The receiver attaches it to the
handler's IncomingRequest, so it is released once that request
drains: the handler and its background work finish, time out, or
abort. TraceCustomEvent and TailStreamCustomEvent carry the
capability, and forward the same one when they send the event over
RPC. A receiver that predates the field ignores it, releasing it on
arrival.

For an actor receiver, a later request takes over the actor's
background work, and the earlier request stops draining. The
capability can then be released while the handler's work continues.
@git-bruh
git-bruh force-pushed the pkhanna/trace-completion branch from ae67da6 to 8c5586c Compare October 22, 2026 15:37
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