Skip to content

Conversation

fhanau
Copy link
Contributor

@fhanau fhanau commented Apr 27, 2025

The revoker membrane was an artifact of trace-stream being ported from JSRPC and should not be needed here.

Copy link
Collaborator

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

As mentioned on our call yesterday, this looks like the correct change ut would feel more comfortable if @kentonv could review as well

@fhanau
Copy link
Contributor Author

fhanau commented May 5, 2025

As mentioned on our call yesterday, this looks like the correct change ut would feel more comfortable if @kentonv could review as well

@kentonv

kentonv
kentonv previously requested changes May 6, 2025
Copy link
Member

@kentonv kentonv left a comment

Choose a reason for hiding this comment

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

I don't think this is right.

If you are seeing this membrane actually revoke anything, that implies that capabilities associated with the session were still open at the time that sendRpc() finished or was canceled. It's important that capabilities associated with the event don't remain live beyond the lifetime of the event itself. That's exactly what the revoker is enforcing.

Now, it may be true that this revoker pattern isn't really needed: if the caller of sendRpc() always made sure to drop all capabilities before canceling it, and if it only completed normally after all capabilities had been dropped, then there's no need to revoke anything. For many event types, this is a reasonable assumption. JSRPC only needs the revoker because it lets the application send arbitrary capabilities, and since we can't force the application to clean up after itself, we have to forcefully revoke things.

HOWEVER, if the revoker actually is revoking something in your case, that implies that you have some other bug which the revoker is uncovering. Somehow, you're either keeping capabilities open too long, or sendRpc() is completing prematurely, or both. That's the real bug you need to fix -- deleting the revoker doesn't actually fix it.

@fhanau fhanau force-pushed the felix/041825-tail-worker-cleanup2 branch from f6d4cea to 3b77ba6 Compare May 18, 2025 21:44
@fhanau
Copy link
Contributor Author

fhanau commented May 19, 2025

Managed to fix the cancellation issue for the affected RPC-based test after some debugging and internal discussion. Some open questions remain:

  • I assume that the other doneFulfiller->fulfill() calls used in error cases should also be converted to only fulfill the fulfiller later on?
  • Based on Kenton's comment, I think removing the revocation membrane now is acceptable (assuming we are convinced that capabilities are cleaned up properly now), so I kept the removal for now. Keeping it doesn't seem crazy either.
  • Based on Dan's suggestion, is the CompletionMembrane still needed based on keeping customEvent alive while there are live capabilities, or was it only really needed alongside the RevokerMembrane?

@fhanau fhanau marked this pull request as ready for review May 21, 2025 16:12
@fhanau fhanau requested review from a team as code owners May 21, 2025 16:12
@fhanau
Copy link
Contributor Author

fhanau commented May 21, 2025

Managed to fix the cancellation issue for the affected RPC-based test after some debugging and internal discussion. Some open questions remain:

  • I assume that the other doneFulfiller->fulfill() calls used in error cases should also be converted to only fulfill the fulfiller later on?
  • Based on Kenton's comment, I think removing the revocation membrane now is acceptable (assuming we are convinced that capabilities are cleaned up properly now), so I kept the removal for now. Keeping it doesn't seem crazy either.
  • Based on Dan's suggestion, is the CompletionMembrane still needed based on keeping customEvent alive while there are live capabilities, or was it only really needed alongside the RevokerMembrane?

@kentonv is the CompletionMembrane still needed here?

@fhanau fhanau force-pushed the felix/041825-tail-worker-cleanup2 branch 2 times, most recently from 373cc1a to 74f36b6 Compare May 29, 2025 16:23
fhanau added 2 commits June 2, 2025 17:34
The revoker membrane warning happened because the revoker membrane was revoked
when the client-side capability was deallocated, only doing that when the
customEvent is complete resolves this issue.
Additionally, draining the tail stream IOContext must be awaited synchronously
so that the customEvent returns when it is done, avoiding cancellations.
@fhanau fhanau force-pushed the felix/041825-tail-worker-cleanup2 branch from 74f36b6 to 0e91fc9 Compare June 3, 2025 03:33
@fhanau fhanau changed the title [DRAFT][o11y] Fix tail stream cancellation warning [o11y] Fix tail stream cancellation warning Jun 3, 2025
@fhanau fhanau merged commit 2f09279 into main Jun 3, 2025
18 of 19 checks passed
@fhanau fhanau deleted the felix/041825-tail-worker-cleanup2 branch June 3, 2025 21:43
fhanau added a commit that referenced this pull request Jun 26, 2025
Change how we drain the TailStreamCustomEventImpl incoming request to how it was
before #4030 (fixing stream cancellation warning): We believe that this caused
drain() to be invoked too late, resulting in "failed to invoke drain()" warnings
and possibly some stream cancellation issues.
fhanau added a commit that referenced this pull request Jul 2, 2025
Change how we drain the TailStreamCustomEventImpl incoming request to how it was
before #4030 (fixing stream cancellation warning): This caused drain() to be
invoked too late, resulting in "failed to invoke drain()" warnings and stream
cancellation issues.
fhanau added a commit that referenced this pull request Jul 7, 2025
Change how we drain the TailStreamCustomEventImpl incoming request to how it was
before #4030 (fixing stream cancellation warning): This caused drain() to be
invoked too late, resulting in "failed to invoke drain()" warnings and stream
cancellation issues.
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.

4 participants