mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Only have timeout for when payload is getState (#14972)
* Only have timeout for when payload is getState Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com> * Fix test Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
This commit is contained in:
parent
5168538afe
commit
3267d6ecc4
@ -18,16 +18,18 @@ class MetaRPCClient {
|
||||
this.requests.set(id, cb);
|
||||
this.connectionStream.write(payload);
|
||||
this.responseHandled[id] = false;
|
||||
setTimeout(() => {
|
||||
if (!this.responseHandled[id] && cb) {
|
||||
delete this.responseHandled[id];
|
||||
return cb(new Error('No response from RPC'), null);
|
||||
}
|
||||
if (payload.method === 'getState') {
|
||||
setTimeout(() => {
|
||||
if (!this.responseHandled[id] && cb) {
|
||||
delete this.responseHandled[id];
|
||||
return cb(new Error('No response from RPC'), null);
|
||||
}
|
||||
|
||||
delete this.responseHandled[id];
|
||||
// needed for linter to pass
|
||||
return true;
|
||||
}, TEN_SECONDS_IN_MILLISECONDS);
|
||||
delete this.responseHandled[id];
|
||||
// needed for linter to pass
|
||||
return true;
|
||||
}, TEN_SECONDS_IN_MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
onNotification(handler) {
|
||||
|
@ -138,7 +138,7 @@ describe('metaRPCClientFactory', () => {
|
||||
const metaRPCClient = metaRPCClientFactory(streamTest);
|
||||
|
||||
const errorPromise = new Promise((_resolve, reject) =>
|
||||
metaRPCClient.foo('bad', (error, _) => {
|
||||
metaRPCClient.getState('bad', (error, _) => {
|
||||
reject(error);
|
||||
}),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user