Browse Source

avoid using promise.finally() which isn't well supported - hopefully fixes #108

fix-133-memory-crash
Dan Janosik 6 years ago
parent
commit
be9c3ccb62
No known key found for this signature in database GPG Key ID: C6F8CE9FFDB2CED2
  1. 19
      app/api/coreApi.js
  2. 10
      app/api/electrumApi.js
  3. 8
      routes/baseActionsRouter.js

19
app/api/coreApi.js

@ -126,13 +126,7 @@ function tryCacheThenRpcApi(cache, cacheKey, cacheMaxAge, rpcApiFunction, cacheC
return new Promise(function(resolve, reject) {
var cacheResult = null;
cache.get(cacheKey).then(function(result) {
cacheResult = result;
}).catch(function(err) {
console.log(`Error nds9fc2eg621tf3: key=${cacheKey}, err=${err}`);
}).finally(function() {
var finallyFunc = function() {
if (cacheResult != null) {
resolve(cacheResult);
@ -148,6 +142,17 @@ function tryCacheThenRpcApi(cache, cacheKey, cacheMaxAge, rpcApiFunction, cacheC
reject(err);
});
}
};
cache.get(cacheKey).then(function(result) {
cacheResult = result;
finallyFunc();
}).catch(function(err) {
console.log(`Error nds9fc2eg621tf3: key=${cacheKey}, err=${err}`);
finallyFunc();
});
});
}

10
app/api/electrumApi.js

@ -38,12 +38,14 @@ function reconnectToServers() {
console.log("Reconnecting ElectrumX sockets...");
connectToServers().catch(function(err) {
console.log("Error 317fh29y7fg3333: " + err);
}).finally(function() {
connectToServers().then(function() {
console.log("Done reconnecting ElectrumX sockets.");
resolve();
}).catch(function(err) {
console.log("Error 317fh29y7fg3333: " + err);
resolve();
});
});

8
routes/baseActionsRouter.js

@ -787,10 +787,14 @@ router.get("/address/:address", function(req, res, next) {
});
}));
Promise.all(promises).catch(function(err) {
Promise.all(promises).then(function() {
res.render("address");
next();
}).catch(function(err) {
console.log("Error 32197rgh327g2: " + err + ", error json: " + JSON.stringify(err));
}).finally(function() {
res.render("address");
next();

Loading…
Cancel
Save