fix: replace dnode background with JSON-RPC#10627
Conversation
|
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. |
097e4dc to
6018fe2
Compare
6018fe2 to
97f4489
Compare
0ec752f to
192e728
Compare
Builds ready [192e728]
Page Load Metrics (575 ± 32 ms)
|
Builds ready [917e701]
Page Load Metrics (652 ± 38 ms)
|
| const cb = this.requests.get(id); | ||
|
|
||
| if (method && params && id) { | ||
| // dont handle server-side to client-side requests |
There was a problem hiding this comment.
Should we throw in this case? This should be unreachable, if I understand this correctly.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)); | ||
| } | ||
| }); |
There was a problem hiding this comment.
adding error handling to a couple places here. could be the source of some uncaught errors?
Builds ready [c1be4ec]
Page Load Metrics (586 ± 55 ms)
|
c1be4ec to
18b5cc9
Compare
|
Removing myself as reviewer for lack of context. I'll be following the conversation to keep up and learn, however. |
18b5cc9 to
a6dfc41
Compare
Builds ready [a6dfc41]
Page Load Metrics (604 ± 35 ms)
|
db4cdc8 to
eb94ff8
Compare
Builds ready [eb94ff8]
Page Load Metrics (610 ± 15 ms)
|
daf2e5f to
91b44e4
Compare
Gudahtt
left a comment
There was a problem hiding this comment.
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.
Builds ready [91b44e4]
Page Load Metrics (630 ± 18 ms)
|
91b44e4 to
111fefd
Compare
Gudahtt
left a comment
There was a problem hiding this comment.
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.
Builds ready [111fefd]
Page Load Metrics (614 ± 39 ms)
|
111fefd to
43ad8bf
Compare
Builds ready [43ad8bf]
Page Load Metrics (637 ± 15 ms)
|

Fixes #10090
Explanation: This replaces our internal use of
dnodewithJSON-RPC.Manual testing steps: