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.

@vercel
Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rivetkit-serverless Error Error Sep 18, 2025 6:10am

Copy link
Member Author

NathanFlurry commented Sep 18, 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.

@claude
Copy link

claude bot commented Sep 18, 2025

Claude finished @NathanFlurry's task —— View job


Code Review Complete

Reviewing the broadcast race condition fix:

  • Read and analyze the changed file
  • Evaluate the race condition fix implementation
  • Check for code quality and best practices
  • Look for potential bugs or issues
  • Assess performance and security considerations
  • Provide comprehensive feedback

Analysis of Changes

The changes address a race condition in the "should receive events via broadcast" test (lines 127-134). The fix moves the event-triggering actions (setCount) inside the vi.waitFor callback to ensure proper synchronization between event subscription and event publishing in SSE (Server-Sent Events).

Changes Made:

  • Moved await connection.setCount(5) and await connection.setCount(8) inside the vi.waitFor async callback
  • Changed from increment to setCount operations
  • Added a comment acknowledging the SSE subscription/event race condition
  • Changed waitFor callback from sync to async

Code Review Feedback

Positive Aspects:

  1. Consistent Pattern: This fix follows the same pattern used in other tests in the file (lines 93-97, 182-185) that also address SSE race conditions
  2. Proper Async Handling: Correctly made the waitFor callback async to handle the asynchronous setCount operations
  3. Clear Documentation: Added a helpful comment explaining the race condition being addressed
  4. Maintains Test Intent: The test still validates broadcast event functionality while fixing the timing issue

⚠️ Areas for Improvement:

  1. API Inconsistency: Changed from increment() to setCount() - while this works, it changes the test's focus from testing incremental operations to absolute value setting. Consider if this affects test coverage.

  2. Repeated Pattern: This is the third instance of similar race condition fixes in the same file. Consider:

    • Creating a helper function to encapsulate this pattern
    • Adding more robust synchronization mechanisms in the actual implementation
    • Documenting this as a known issue with SSE event ordering
  3. Error Handling: The vi.waitFor doesn't specify timeout or interval options like other tests in the file (see lines 273-277). Consider adding explicit timeout configuration for consistency.

🐛 Potential Issues:

  • Test Values: Changed from testing values 5, 8 (via increment) to 5, 8 (via setCount). This coincidentally works but could mask issues if the previous test state isn't properly reset.

🔧 Suggestions:

// Consider this more explicit pattern:
await vi.waitFor(async () => {
    await connection.setCount(5);
    await connection.setCount(8);
    expect(receivedEvents).toContain(5);
    expect(receivedEvents).toContain(8);
}, {
    timeout: 5000,
    interval: 100
});

📊 Overall Assessment:

This is a good fix that addresses a real race condition issue. The solution is consistent with other similar fixes in the codebase and properly handles the async nature of SSE event broadcasting. The main concern is the accumulation of these workarounds suggests a deeper architectural issue that might benefit from a more systematic solution.

Recommendation: ✅ Approve - This fix resolves the immediate issue and follows established patterns in the codebase.


@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 18, 2025

More templates

@rivetkit/actor

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/actor@1284

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/cloudflare-workers@1284

@rivetkit/core

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/core@1284

@rivetkit/db

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/db@1284

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/framework-base@1284

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/next-js@1284

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/react@1284

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivetkit@1284

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/sql-loader@1284

commit: b4196e5

@graphite-app
Copy link

graphite-app bot commented Sep 24, 2025

Merge activity

  • Sep 24, 6:06 AM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Sep 24, 6:07 AM UTC: CI is running for this pull request on a draft pull request (#1294) due to your merge queue CI optimization settings.
  • Sep 24, 6:08 AM UTC: Merged by the Graphite merge queue via draft PR: #1294.

graphite-app bot pushed a commit that referenced this pull request Sep 24, 2025
@graphite-app graphite-app bot closed this Sep 24, 2025
@graphite-app graphite-app bot deleted the 09-17-chore_core_fix_broadcast_race_condition branch September 24, 2025 06:08
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