Skip to content

fix: replace dnode background with JSON-RPC#10627

Merged
shanejonas merged 1 commit intodevelopfrom
fix/replace-dnode-metamask-controller
Mar 18, 2021
Merged

fix: replace dnode background with JSON-RPC#10627
shanejonas merged 1 commit intodevelopfrom
fix/replace-dnode-metamask-controller

Conversation

@shanejonas
Copy link
Contributor

@shanejonas shanejonas commented Mar 10, 2021

Fixes #10090

Explanation: This replaces our internal use of dnode with JSON-RPC.

Manual testing steps:

  • make sure everything still works, this is a cross-cutting change that affects most (if not all) of the application

@shanejonas shanejonas requested a review from a team as a code owner March 10, 2021 21:39
@shanejonas shanejonas requested a review from darkwing March 10, 2021 21:39
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@shanejonas shanejonas requested review from Gudahtt and rekmarks March 10, 2021 21:40
@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch from 097e4dc to 6018fe2 Compare March 10, 2021 22:12
@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch from 6018fe2 to 97f4489 Compare March 10, 2021 22:24
@brad-decker
Copy link
Contributor

image

@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch 6 times, most recently from 0ec752f to 192e728 Compare March 12, 2021 23:42
@metamaskbot
Copy link
Collaborator

Builds ready [192e728]
Page Load Metrics (575 ± 32 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint468759105
domContentLoaded3766245746732
load3776255756732
domInteractive3766245746732

@metamaskbot
Copy link
Collaborator

Builds ready [917e701]
Page Load Metrics (652 ± 38 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint498865115
domContentLoaded4227856507938
load4237866527938
domInteractive4227846507938

const cb = this.requests.get(id);

if (method && params && id) {
// dont handle server-side to client-side requests
Copy link
Member

Choose a reason for hiding this comment

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

Should we throw in this case? This should be unreachable, if I understand this correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

one of the reasons I have this is because calling write postMessage/websocket/portStream doesn't fire data on its own stream, but my testStream does and ends up here.

Copy link
Member

Choose a reason for hiding this comment

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

I played around with this today but didn't quite manage to get it to work. We can improve this later if we get around to it - I don't see any reason to block on it.

return;
}
if (!cb) {
// not found in request list
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, we might want to throw here. I'm guessing that it is possible we'll hit this case, if we every reply twice for any reason. But if we're doing that, it would be a bug that we'd want to track down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could happen if you made 2 instance of this class. One of them would try to handle an id it doesn't care about.

Copy link
Member

Choose a reason for hiding this comment

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

That would still be a bug, wouldn't it? At least I can't think of a case where this would be expected. Even if there were two instances, hopefully they'd be handling different sets of requests, i.e. we wouldn't have a request from one reply to the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const client1 = metaRPCClientFactory(connectionStream);
client1.bar();
// random id: 123456

const client2 = metaRPCClientFactory(connectionStream);
client2.baz();
// random id: 54321

in this example, by calling baz() on client2 would still get a result over connectionStream triggering onResponse on client1 which then would look for a callback (54321) it doesn't care about.

Copy link
Member

Choose a reason for hiding this comment

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

Ohhhhhh I see, I get it now. Thanks, I didn't realize this would broadcast each reply to all clients.

Is that how our post message stream works? 🤔

if (err) {
dispatch(displayWarning(err.message));
}
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding error handling to a couple places here. could be the source of some uncaught errors?

@metamaskbot
Copy link
Collaborator

Builds ready [c1be4ec]
Page Load Metrics (586 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint47735873
domContentLoaded34374258511555
load34574358611555
domInteractive34374258511555

@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch from c1be4ec to 18b5cc9 Compare March 17, 2021 16:58
@darkwing
Copy link
Contributor

Removing myself as reviewer for lack of context. I'll be following the conversation to keep up and learn, however.

@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch from 18b5cc9 to a6dfc41 Compare March 17, 2021 18:15
@metamaskbot
Copy link
Collaborator

Builds ready [a6dfc41]
Page Load Metrics (604 ± 35 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint428254115
domContentLoaded5388346037335
load5398356047335
domInteractive5378346037335

@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch from db4cdc8 to eb94ff8 Compare March 17, 2021 20:03
@metamaskbot
Copy link
Collaborator

Builds ready [eb94ff8]
Page Load Metrics (610 ± 15 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint45755894
domContentLoaded5516976093115
load5526986103115
domInteractive5516976083115

@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch 2 times, most recently from daf2e5f to 91b44e4 Compare March 18, 2021 17:05
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

Everything looks good to me aside from possibly the .node-version file, only because I don't know what that is. There is room for improvement with the error handling but I don't think that should be a blocker.

@metamaskbot
Copy link
Collaborator

Builds ready [91b44e4]
Page Load Metrics (630 ± 18 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint49725974
domContentLoaded5627516283919
load5637526303818
domInteractive5627516283919

@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch from 91b44e4 to 111fefd Compare March 18, 2021 17:23
Gudahtt
Gudahtt previously approved these changes Mar 18, 2021
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

I tried testing this, and I did confirm that the stack is present on the error in the UI, representing exactly what went wrong in the background. Not sure yet how it shows up in Sentry, but I expect that it'll work.

@metamaskbot
Copy link
Collaborator

Builds ready [111fefd]
Page Load Metrics (614 ± 39 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint448256115
domContentLoaded5439086138240
load5449106148239
domInteractive5439086128240

@shanejonas shanejonas force-pushed the fix/replace-dnode-metamask-controller branch from 111fefd to 43ad8bf Compare March 18, 2021 18:06
@metamaskbot
Copy link
Collaborator

Builds ready [43ad8bf]
Page Load Metrics (637 ± 15 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint478060105
domContentLoaded5927336363215
load5927346373215
domInteractive5917336363215

@shanejonas shanejonas merged commit b50fe31 into develop Mar 18, 2021
@shanejonas shanejonas deleted the fix/replace-dnode-metamask-controller branch March 18, 2021 18:23
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background errors not serialized correctly when sent to UI

6 participants