Skip to content

Conversation

@FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Jan 13, 2026

Adds a mutex to the wallet_requestSnaps handler to prevent race conditions if multiple concurrent requests are sent from the same origin. Since Snaps are defined as caveats we need to merge permissions and for that we need the most up-to-date permissions-set, without this change we would be merging with stale data.

Recommend reviewing this PR with whitespace diff hidden.


Note

Prevents concurrent processing of wallet_requestSnaps that could race when merging permissions.

  • Introduces a per-origin Mutex in requestSnaps.ts and wraps the permission/install flow in runExclusive, using the request origin to serialize operations
  • Moves empty-params validation outside the try/catch for earlier exit; preserves error handling by setting res.error within the mutex block
  • Slightly updates coverage thresholds in jest.config.js

Written by Cursor Bugbot for commit 0e1386e. This will update automatically on new commits. Configure here.

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.33%. Comparing base (15a9666) to head (0e1386e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3800   +/-   ##
=======================================
  Coverage   98.33%   98.33%           
=======================================
  Files         422      422           
  Lines       12073    12082    +9     
  Branches     1875     1876    +1     
=======================================
+ Hits        11872    11881    +9     
  Misses        201      201           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@FrederikBolding FrederikBolding marked this pull request as ready for review January 13, 2026 13:21
@FrederikBolding FrederikBolding requested a review from a team as a code owner January 13, 2026 13:21
@FrederikBolding FrederikBolding added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit 6f79d0c Jan 13, 2026
128 checks passed
@FrederikBolding FrederikBolding deleted the fb/request-snaps-race-condition branch January 13, 2026 13:21
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