Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add log in dbsync healthCheck #320

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions dbsync-api/src/health/healthCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const getBlockInfo = async (req: Request, res: Response) => {
});

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

if (timeDiff > 300) {
return res.status(503).json({
const body = {
status: "Service Unavailable",
details: {
...blockInfo,
currentTime: new Date().toISOString(),
secondsSinceLastUpdate: timeDiff,
},
});
}
console.log(`DbSync BlockTimeDifferenceError: ${body}`);
return res.status(503).json(body);
}

return res.status(200).json({
Expand Down
Loading