mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 10:45:10 +02:00
Always return cached value when thegraph errors
This commit is contained in:
parent
e0795f8bf2
commit
d6bfdc2551
@ -585,6 +585,7 @@ apiRouter.get("/getTickets", async (req, res) => {
|
|||||||
|
|
||||||
// Gets info on a given Orchestrator
|
// Gets info on a given Orchestrator
|
||||||
const parseOrchestrator = async function (reqAddr) {
|
const parseOrchestrator = async function (reqAddr) {
|
||||||
|
try {
|
||||||
reqAddr = reqAddr.toLowerCase();
|
reqAddr = reqAddr.toLowerCase();
|
||||||
const now = new Date().getTime();
|
const now = new Date().getTime();
|
||||||
// Default assume it's the first time we request this Orchestrator
|
// Default assume it's the first time we request this Orchestrator
|
||||||
@ -668,6 +669,19 @@ const parseOrchestrator = async function (reqAddr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return orchestratorObj;
|
return orchestratorObj;
|
||||||
|
} catch (err) {
|
||||||
|
if (wasCached) {
|
||||||
|
console.log("Thegraph is probably acting up. Returning cached value...");
|
||||||
|
for (var idx = 0; idx < orchestratorCache.length; idx++) {
|
||||||
|
if (orchestratorCache[idx].id == reqAddr) {
|
||||||
|
return orchestratorCache[idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else{
|
||||||
|
console.log("Thegraph is probably acting up, but there is no cached value. Returning null...");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exports info on a given Orchestrator
|
// Exports info on a given Orchestrator
|
||||||
@ -678,7 +692,7 @@ apiRouter.get("/getOrchestrator", async (req, res) => {
|
|||||||
reqOrch = CONF_DEFAULT_ORCH;
|
reqOrch = CONF_DEFAULT_ORCH;
|
||||||
}
|
}
|
||||||
const reqObj = await parseOrchestrator(reqOrch);
|
const reqObj = await parseOrchestrator(reqOrch);
|
||||||
res.send(JSON.stringify(reqObj));
|
res.send(reqObj);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
res.status(400).send(err);
|
res.status(400).send(err);
|
||||||
@ -687,7 +701,7 @@ apiRouter.get("/getOrchestrator", async (req, res) => {
|
|||||||
apiRouter.get("/getOrchestrator/:orch", async (req, res) => {
|
apiRouter.get("/getOrchestrator/:orch", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const reqObj = await parseOrchestrator(req.params.orch);
|
const reqObj = await parseOrchestrator(req.params.orch);
|
||||||
res.send(JSON.stringify(reqObj));
|
res.send(reqObj);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
res.status(400).send(err);
|
res.status(400).send(err);
|
||||||
@ -696,7 +710,7 @@ apiRouter.get("/getOrchestrator/:orch", async (req, res) => {
|
|||||||
apiRouter.post("/getOrchestrator", async (req, res) => {
|
apiRouter.post("/getOrchestrator", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const reqObj = await parseOrchestrator(req.body.orchAddr);
|
const reqObj = await parseOrchestrator(req.body.orchAddr);
|
||||||
res.send(JSON.stringify(reqObj));
|
res.send(reqObj);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
res.status(400).send(err);
|
res.status(400).send(err);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user