Merge pull request #1791 from zahar517/fix-json-rpc-example

Fix json-rpc-over-ws example
This commit is contained in:
Sergey Lyubka 2022-10-10 10:35:29 +01:00 committed by GitHub
commit 3b95671442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,12 +23,12 @@ var jsonrpc = function(url, onopen, onclose, onnotification) {
ws.send(JSON.stringify(request));
console.log('sent', request);
return new Promise(function(resolve, reject) {
setTimeout(JSONRPC_TIMEOUT_MS, function() {
setTimeout(function() {
if (pending[id] === undefined) return;
log('Timing out frame ', JSON.stringify(request));
delete (pending[id]);
reject();
});
}, JSONRPC_TIMEOUT_MS);
pending[id] = x => resolve(x);
});
},