Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure useEffect does not spam closeWeb3Modal + close event #405

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

bkrem
Copy link
Member

@bkrem bkrem commented Jan 16, 2024

Description

  • Bug: This useEffect is called in a loop for the duration of the signature modal being open
    • It was also calling closeWeb3Modal unchecked i.e. even if w3m was already in a closed state
    • This was causing our analytics endpoint to be spammed with MODAL_CLOSE events which could lead to unintentional request floods from users that leave the app in this state.
  • This patch ensures we first check open: boolean state for w3m before explicitly calling closeWeb3Modal
  • This patch does not root cause why this useEffect goes into a loop once the signature modal opens, this is TBD.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Draft PR (breaking/non-breaking change which needs more work for having a proper functionality [Mark this PR as ready to review only when completely ready])
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Examples/Screenshots (Optional)

Reproduction

  1. Go to app.web3inbox.com (or a preview that has w3m analytics enabled)
  2. Use a fresh account or reset client state to ensure you get the secondary "Sign notify message" popup after w3m connect
  3. Observe network tab after initial w3m connect; spamming the pulse.walletconnect.com/e endpoint with MODAL_CLOSE events (see screenshot)

Screenshots

Screenshot 2024-01-16 at 12 10 54

Checklist:

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@bkrem bkrem requested review from enesozturk and devceline January 16, 2024 11:19
Copy link

vercel bot commented Jan 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app-web3inbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 16, 2024 11:30am

Copy link
Collaborator

@devceline devceline left a comment

Choose a reason for hiding this comment

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

It looks good to me bar the Notification access

src/Modals.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@devceline devceline left a comment

Choose a reason for hiding this comment

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

LGTM

@bkrem bkrem merged commit 1a8d284 into main Jan 16, 2024
3 checks passed
enesozturk pushed a commit that referenced this pull request Jan 18, 2024
)

* fix: ensure useEffect does not spam `closeWeb3Modal` + close event

* chore: disable ESLint warning on `Notification?.permission` chaining
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.

3 participants