Skip to content

fix: deduplicate event subscriptions across hooks (#833) - #849

Open
Peolite001 wants to merge 16 commits into
Iris-IV:mainfrom
Peolite001:fix/duplicate-event-subscriptions
Open

fix: deduplicate event subscriptions across hooks (#833)#849
Peolite001 wants to merge 16 commits into
Iris-IV:mainfrom
Peolite001:fix/duplicate-event-subscriptions

Conversation

@Peolite001

Copy link
Copy Markdown

Summary

This PR migrates useCampaignContributionEvents and useCampaignVoteEvents to use the shared eventSubscriber instance instead of maintaining their own individual polling loops.

Previously, if multiple components observed the same campaign on a single page, each hook consumer instantiated a separate RPC polling interval. By routing them through eventSubscriber, the app now shares a single underlying Soroban event polling stream for the contract across all hooks and deduplicates events efficiently.

Closes #833

Type of Change

  • Bug fix
  • Feature
  • Chore / maintenance
  • Documentation
  • Test coverage

Contributor Checklist

  • Linked the related issue above.
  • Reviewed CONTRIBUTING.md for branch, commit, and PR title conventions.
  • Confirmed this follows the current Stellar Wave contribution flow, if applicable.
  • Added or updated tests when behavior changed.
  • Updated docs, examples, or translations when needed. (Added a note inside eventSubscriber.ts)

Validation

  • npm run lint
  • npm run format:check
  • npm run typecheck
  • npm test
  • npm run build
  • Not run; reason: Local test suite execution failed (jest not found in local environment), but code was structurally verified. Please run standard CI pipelines against this branch.

Notes for Reviewers

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Peolite001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

1 similar comment
@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@Peolite001
Peolite001 force-pushed the fix/duplicate-event-subscriptions branch from b9d5e05 to 8fa9e7a Compare July 31, 2026 06:38
@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

Comment thread scripts/check-i18n.mjs
const parts = fullKey.split(".");
const key = parts[parts.length - 1];
const namespace = parts.length > 1 ? parts[0] : '';
const namespace = parts.length > 1 ? parts[0] : "";
@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

Comment thread tests/e2e/withdrawal.spec.ts Fixed
@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

// Step 3: Check for withdrawal action button or navigate directly to withdraw tab
const withdrawBtn = page.getByRole("button", { name: /withdraw|claim/i }).or(page.locator("body"));
await expect(withdrawBtn).toBeVisible();
const withdrawBtn = page.getByRole("button", { name: /withdraw|claim/i }).first();
@sshdopey

sshdopey commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

sshdopey commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@davidmaronio davidmaronio left a comment

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.

routing useCampaignContributionEvents and useCampaignVoteEvents through the shared eventSubscriber is exactly what #833 asked for, and the lazy rpc.Server construction is a nice touch for tests. before it can merge:

  1. the diff spans 38 files, most of it unrelated churn: README/PRE_COMMIT_SETUP, jest config, markdown mocks, and pure formatting rewrites of gamification.ts, badges.ts, middleware.ts, etc. please rebase onto current main so the diff shrinks to the subscriber migration; right now the real change is impossible to review in isolation and the branch is in conflict with main.
  2. src/hooks/useCampaignContributionEvents.ts:48: the hook calls eventSubscriber.start() but cleanup only does off(). does the subscriber stop its polling loop when the last handler is removed? if not, navigating away from campaign pages leaves a global rpc poll running forever; a ref-counted stop would close that.
  3. note #705 touches the same hook with a different approach; whichever lands second needs coordination.

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.

[Performance] eventSubscriber.ts may open duplicate Soroban event subscriptions per hook consumer

4 participants