Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Conversation

@NathanFlurry
Copy link
Member

No description provided.

@claude
Copy link

claude bot commented Sep 10, 2025

Claude finished @NathanFlurry's task —— View job


Code Review: SSE Connection Disconnect Fix

I've completed my review of this PR that fixes disconnecting SSE connections. Here are my findings:

Review Checklist:

  • Read and understand the changed files
  • Analyze code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Review security concerns
  • Assess test coverage
  • Provide comprehensive feedback

Overall Assessment: Good Fix

This PR properly addresses SSE connection cleanup issues with clean, focused changes.

📋 Key Changes

  1. Fixed SSE abort handling (router-endpoints.ts:363-386)
  2. Re-enabled SSE transport tests (mod.ts:91)
  3. Improved test reliability (actor-conn.ts:87-108)

🔍 Detailed Review

packages/core/src/actor/router-endpoints.ts

Strengths:

  • Proper event handling: Correctly switched from c.req.raw.signal.addEventListener("abort") to stream.onAbort() - this is the proper way to handle SSE stream disconnections
  • Resource cleanup: Properly removes connections from global state and calls actor.__removeConn(conn)
  • Error handling: Good error handling with logging and resolver cleanup on both success and error paths
  • Clear logging: Updated log messages are more descriptive ("sse stream aborted" vs "sse shutting down")

Code Quality:

  • Clean removal of unnecessary HACK comment and workaround code
  • Consistent error handling pattern with the rest of the codebase
  • Proper use of promise resolvers for async cleanup

packages/core/src/driver-test-suite/mod.ts

Strengths:

  • Confidence in fix: Re-enabling SSE tests shows confidence the fix works
  • Good test coverage: Ensures both WebSocket and SSE transports are tested

packages/core/src/driver-test-suite/tests/actor-conn.ts

Strengths:

  • Better test reliability: Using promise-based event waiting instead of timing-dependent expectations
  • Race condition fix: Properly waits for all expected events before asserting, preventing flaky tests
  • Clear intent: Test logic is more explicit about what it's waiting for

🚀 Performance Considerations

  • Improved cleanup: Proper SSE cleanup should prevent resource leaks
  • Faster disconnect detection: Using stream.onAbort() should detect disconnections more quickly than polling request signals

🔒 Security Assessment

  • No security concerns identified
  • Proper cleanup prevents potential resource exhaustion
  • No sensitive data exposure risks

🧪 Test Coverage Assessment

  • Excellent: SSE transport tests are now re-enabled
  • Race condition fix: Test improvements make the suite more reliable
  • Comprehensive coverage: Tests cover WebSocket, SSE, and various connection scenarios

🎯 Minor Suggestions

  1. Consider adding a timeout in router-endpoints.ts:394:

    // Wait until connection aborted
    await abortResolver.promise;

    Consider adding a timeout to prevent indefinite waiting, though this may not be necessary given the SSE stream lifecycle.

  2. Potential enhancement: The error handling in the abort callback could potentially differentiate between expected disconnects and actual errors, but the current approach is adequate.


Approval Recommendation

This is a solid fix that:

  • ✅ Properly addresses the SSE disconnection issue
  • ✅ Follows existing code patterns and best practices
  • ✅ Includes proper test coverage
  • ✅ Has no security or performance concerns
  • ✅ Improves system reliability

The changes are focused, well-tested, and use the correct Hono SSE APIs. This should resolve the SSE connection disconnect issues mentioned in the PR title.


Copy link
Member Author

NathanFlurry commented Sep 10, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@graphite-app
Copy link

graphite-app bot commented Sep 11, 2025

Merge activity

  • Sep 11, 10:34 PM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Sep 11, 10:35 PM UTC: CI is running for this pull request on a draft pull request (#1206) due to your merge queue CI optimization settings.
  • Sep 11, 10:35 PM UTC: Merged by the Graphite merge queue via draft PR: #1206.

@graphite-app graphite-app bot closed this Sep 11, 2025
@graphite-app graphite-app bot deleted the 09-10-fix_core_fix_disconnecting_sse_connections branch September 11, 2025 22:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants