mirror of
https://github.com/janoside/btc-rpc-explorer.git
synced 2026-08-13 12:33:13 +02:00
Fix #442
There was a race condition where multiple frontend requests could be sent trying to retrieve the mining summary data. The first request got the data and cleared it, the second request got an empty response, then encountered an error trying to work with it.
This commit is contained in:
parent
d30b13a15f
commit
6f2c5470e6
3 changed files with 11 additions and 8 deletions
|
|
@ -203,7 +203,8 @@ router.get("/get-mempool-summary", asyncHandler(async (req, res, next) => {
|
|||
delete mempoolSummaryStatuses[statusId];
|
||||
|
||||
} else {
|
||||
res.json({});
|
||||
res.writeHead(204);
|
||||
res.end("no summary for that id");
|
||||
|
||||
next();
|
||||
}
|
||||
|
|
@ -275,7 +276,8 @@ router.get("/get-mining-summary", asyncHandler(async (req, res, next) => {
|
|||
delete miningSummaryStatuses[statusId];
|
||||
|
||||
} else {
|
||||
res.json({});
|
||||
res.writeHead(204);
|
||||
res.end("no summary for that id");
|
||||
|
||||
next();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ block endOfBody
|
|||
url: `./internal-api/get-mempool-summary?statusId=${statusId}`
|
||||
|
||||
}).done((summaryResult) => {
|
||||
if (summaryResult.count) {
|
||||
if (summaryResult && summaryResult.count) {
|
||||
summary = summaryResult;
|
||||
|
||||
$("#json-content").text(JSON.stringify(summaryResult, null, 4));
|
||||
|
|
|
|||
|
|
@ -124,14 +124,15 @@ block endOfBody
|
|||
url: `./internal-api/get-mining-summary?statusId=${statusId}`
|
||||
|
||||
}).done((summaryResult) => {
|
||||
summary = summaryResult;
|
||||
if (summaryResult && summaryResult.overall) {
|
||||
summary = summaryResult;
|
||||
|
||||
$("#json-content").text(JSON.stringify(summary, null, 4));
|
||||
$("#json-content").text(JSON.stringify(summary, null, 4));
|
||||
|
||||
hljs.highlightAll();
|
||||
|
||||
displaySummaryData(summary);
|
||||
hljs.highlightAll();
|
||||
|
||||
displaySummaryData(summary);
|
||||
}
|
||||
}).always(() => {
|
||||
// nothing
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue