Skip to content

Commit 39d56f3

Browse files
authored
Merge pull request #320 from cardanoapi/fix/dbsync-healthcheck-log
fix: Add log in dbsync healthCheck
2 parents 958aa1b + 8592f52 commit 39d56f3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

dbsync-api/src/health/healthCheck.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const getBlockInfo = async (req: Request, res: Response) => {
2323
});
2424

2525
if (!latestBlock) {
26+
console.log("Unable to retrieve the latest block information from the database.");
2627
return res.status(500).json({
2728
message:
2829
"Unable to retrieve the latest block information from the database.",
@@ -38,14 +39,16 @@ const getBlockInfo = async (req: Request, res: Response) => {
3839
const timeDiff = secondsSince(blockInfo.blockTime);
3940

4041
if (timeDiff > 300) {
41-
return res.status(503).json({
42+
const body = {
4243
status: "Service Unavailable",
4344
details: {
4445
...blockInfo,
4546
currentTime: new Date().toISOString(),
4647
secondsSinceLastUpdate: timeDiff,
4748
},
48-
});
49+
}
50+
console.log(`DbSync BlockTimeDifferenceError: ${body}`);
51+
return res.status(503).json(body);
4952
}
5053

5154
return res.status(200).json({

0 commit comments

Comments
 (0)