fix(@embark/geth): fix version result not available

This commit is contained in:
Jonathan Rainville 2019-10-28 11:40:16 -04:00 committed by Michael Bradley
parent 1302f9fb48
commit 9803507221
1 changed files with 9 additions and 1 deletions

View File

@ -4,7 +4,15 @@ const http = require("http");
const LIVENESS_CHECK=`{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":42}`;
const parseAndRespond = (data, cb) => {
const resp = JSON.parse(data);
let resp;
try {
resp = JSON.parse(data);
} catch (e) {
return cb('Version data is not valid JSON');
}
if (!resp || !resp.result) {
return cb('No version returned');
}
const [_, version, __] = resp.result.split('/');
cb(null, version);
};