Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
janoside committed May 12, 2022
1 parent d30b13a commit 6f2c547
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions routes/internalApiRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion views/mempool-summary.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
11 changes: 6 additions & 5 deletions views/mining-summary.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down

0 comments on commit 6f2c547

Please sign in to comment.