From 07360f784b26a1acd7cad8c7566c00bd671689b4 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Tue, 13 Jun 2017 17:52:29 -0700 Subject: [PATCH] added timeout to get call --- helpers/lbryApi.js | 16 +++++++--------- helpers/lbryHelpers.js | 1 - 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/helpers/lbryApi.js b/helpers/lbryApi.js index 49d8cc76..394c30cb 100644 --- a/helpers/lbryApi.js +++ b/helpers/lbryApi.js @@ -17,22 +17,20 @@ module.exports = { }); return deferred; }, - getClaim: function(uri){ // note: move to lbryApi + getClaim: function(uri){ var deferred = new Promise(function(resolve, reject){ - console.log(">> making get request to lbry daemon"); axios.post('http://localhost:5279/lbryapi', { "method": "get", - "params": { "uri": uri } + "params": { "uri": uri, "timeout": 30} }).then(function (getResponse) { console.log(">> 'get claim' success..."); - //check to make sure the daemon didn't just time out (or otherwise send an error that appears to be a success?) - // if (getResponse.data.result.error){ - // reject(getResponse.data.result.error); - // } - console.log(">> response data:", getResponse.data); + //check to make sure the daemon didn't just time out (or otherwise send an error that appears to be a success response) + if (getResponse.data.result.error){ + reject(getResponse.data.result.error); + } // resolve the promise with the download path for the claim we got /* - note: put in a check to make sure we do not resolve until the download is actually complete (total_bytes should match written_bytes) + note: put in a check to make sure we do not resolve until the download is actually complete (response.data.completed === true) */ resolve(getResponse.data); }).catch(function(getUriError){ diff --git a/helpers/lbryHelpers.js b/helpers/lbryHelpers.js index 808ca6f9..58118f64 100644 --- a/helpers/lbryHelpers.js +++ b/helpers/lbryHelpers.js @@ -93,7 +93,6 @@ module.exports = { }); return deferred; }, - getClaimBasedOnUri: function(uri){ /* to do: need to pass the URI through a test to see if it is free and public. Right now it is jumping straight to 'get'ing and serving the asset.