-
Notifications
You must be signed in to change notification settings - Fork 639
refactor: Simplify RPC handling in SnapController #3397
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
Conversation
f5a49ff to
9f713d1
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3397 +/- ##
==========================================
+ Coverage 98.13% 98.14% +0.01%
==========================================
Files 400 399 -1
Lines 11027 10990 -37
Branches 1738 1729 -9
==========================================
- Hits 10821 10786 -35
+ Misses 206 204 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9f713d1 to
dff1689
Compare
dff1689 to
6df8fb0
Compare
| const result = await withTimeout(handleRpcRequestPromise, timer); | ||
|
|
||
| if (result === hasTimedOut) { | ||
| throw new Error(`${snapId} failed to respond to the request in time.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
| throw new Error(`${snapId} failed to respond to the request in time.`); | |
| throw new Error(`Snap "${snapId}" failed to respond to the request in time.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently mirrors the error message from the execution service: https://github.com/MetaMask/snaps/blob/fb/simplify-controller-rpc/packages/snaps-controllers/src/services/AbstractExecutionService.ts#L378
IMO keep as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferably we update those too, but fine with me to do in a separate PR as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO out of scope then 😄
Stop storing an RPC handler in the runtime for Snaps, instead just move the handler code directly to
handleRequest. Also removes theRequestQueuepreviously used during the Snap starting up, instead we let as many requests as needed wait forstartPromise. This simplifies RPC request routing significantly.Recommend reviewing this with whitespace changes not displayed 😄