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
app/scripts/lib
@ -18,16 +18,18 @@ class MetaRPCClient {
|
|||||||
this.requests.set(id, cb);
|
this.requests.set(id, cb);
|
||||||
this.connectionStream.write(payload);
|
this.connectionStream.write(payload);
|
||||||
this.responseHandled[id] = false;
|
this.responseHandled[id] = false;
|
||||||
setTimeout(() => {
|
if (payload.method === 'getState') {
|
||||||
if (!this.responseHandled[id] && cb) {
|
setTimeout(() => {
|
||||||
delete this.responseHandled[id];
|
if (!this.responseHandled[id] && cb) {
|
||||||
return cb(new Error('No response from RPC'), null);
|
delete this.responseHandled[id];
|
||||||
}
|
return cb(new Error('No response from RPC'), null);
|
||||||
|
}
|
||||||
|
|
||||||
delete this.responseHandled[id];
|
delete this.responseHandled[id];
|
||||||
// needed for linter to pass
|
// needed for linter to pass
|
||||||
return true;
|
return true;
|
||||||
}, TEN_SECONDS_IN_MILLISECONDS);
|
}, TEN_SECONDS_IN_MILLISECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onNotification(handler) {
|
onNotification(handler) {
|
||||||
|
@ -138,7 +138,7 @@ describe('metaRPCClientFactory', () => {
|
|||||||
const metaRPCClient = metaRPCClientFactory(streamTest);
|
const metaRPCClient = metaRPCClientFactory(streamTest);
|
||||||
|
|
||||||
const errorPromise = new Promise((_resolve, reject) =>
|
const errorPromise = new Promise((_resolve, reject) =>
|
||||||
metaRPCClient.foo('bad', (error, _) => {
|
metaRPCClient.getState('bad', (error, _) => {
|
||||||
reject(error);
|
reject(error);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user