Skip to content

Damus races cherry picked#3653

Draft
danieldaquino wants to merge 7 commits intodamus-io:masterfrom
danieldaquino:damus-races-cherry-picked
Draft

Damus races cherry picked#3653
danieldaquino wants to merge 7 commits intodamus-io:masterfrom
danieldaquino:damus-races-cherry-picked

Conversation

@danieldaquino
Copy link
Copy Markdown
Collaborator

Summary

Cherry picked version of #3638

Work in progress.

Checklist

Experimental Feature Checklist

Tip

This Pull Request is an experimental feature for Damus Labs, and follows a fast-track review process.
The overall requirements are lowered and the review process is not as strict as usual. However, the feature will only be available for Purple users who opt-in.

  • I have read (or I am familiar with) the Contribution Guidelines.
  • I have done some testing on the changes in this PR to ensure it is at least functional.
  • I made sure that this new feature is only available when the user opts-in from the Damus Labs screen, and does not affect the rest of the app when turned off.
  • My PR is either small, or I have split it into smaller logical commits that are easier to review.
  • I have added the signoff line to all my commits. See Signing off your work.
  • I have added an appropriate changelog entry to my commit in this PR. See Adding changelog entries.
    • Example changelog entry: Changelog-Added: Added experimental feature <X> to Damus Labs

Standard PR Checklist

  • I have read (or I am familiar with) the Contribution Guidelines
  • I have tested the changes in this PR
  • I have profiled the changes to ensure there are no performance regressions, or I do not need to profile the changes.
  • I have opened or referred to an existing github issue related to this change.
  • My PR is either small, or I have split it into smaller logical commits that are easier to review
  • I have added the signoff line to all my commits. See Signing off your work
  • I have added appropriate changelog entries for the changes in this PR. See Adding changelog entries
    • I do not need to add a changelog entry. Reason: [Please provide a reason]
  • I have added appropriate Closes: or Fixes: tags in the commit messages wherever applicable, or made sure those are not needed. See Submitting patches

Test report

Please provide a test report for the changes in this PR. You can use the template below, but feel free to modify it as needed.

Device: [Please specify the device you used for testing]

iOS: [Please specify the iOS version you used for testing]

Damus: [Please specify the Damus version or commit hash you used for testing]

Setup: [Please provide a brief description of the setup you used for testing, if applicable]

Steps: [Please provide a list of steps you took to test the changes in this PR]

Results:

  • PASS
  • Partial PASS
    • Details: [Please provide details of the partial pass]

Other notes

[Please provide any other information that you think is relevant to this PR.]

alltheseas and others added 7 commits February 25, 2026 16:08
Actor re-entrancy across `await flush_event` allowed concurrent
`handle_event` calls to mutate `events` and `remaining` mid-iteration.
Snapshot both collections before the loop.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: alltheseas <[email protected]>
…ions

has_ev Set and other collections were accessed from multiple relay
handler streams without synchronization. @mainactor serializes all
access through the main thread.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: alltheseas <[email protected]>
…ubscribeAll

Handler registration and removal can mutate the handlers array between
yield calls during actor re-entrant suspension points. Snapshot the
array before iterating.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: alltheseas <[email protected]>
ConcurrentBarrier, AtomicCounter, ResumeTracker, and concurrentStress
helpers for deterministic race condition testing across all 27 fixes.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: alltheseas <[email protected]>
HomeModel is already @mainactor, which serializes access to
already_reposted and other shared state even when parallel Tasks
call process_event. Tests confirm the serialization is effective.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: alltheseas <[email protected]>
…g callback

The ping callback fires on an arbitrary thread. Writing @published
properties (isConnected, isConnecting) off the main thread can crash
SwiftUI. Wrap in DispatchQueue.main.async.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: alltheseas <[email protected]>
These methods mutate events and incoming arrays that are also accessed
by @mainactor insert(). Without isolation, concurrent filter + insert
leaves has_event and events inconsistent.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: alltheseas <[email protected]>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 26, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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