Skip to content

Commit

Permalink
Merge pull request #280 from duyet/chore/ui
Browse files Browse the repository at this point in the history
chore(api): /api/clean better logging
  • Loading branch information
duyet authored Jun 30, 2024
2 parents b5c2b40 + 6e54b11 commit b46175e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/api/clean/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ async function cleanupHangQuery(
throw new Error(
`Last cleanup was ${lastCleanup} less than ${QUERY_CLEANUP_MAX_DURATION_SECONDS}s`
)
} else {
console.log('[/api/clean] Starting clean up hang queries')
}

type KillQueryResponse = {
Expand Down Expand Up @@ -97,6 +99,7 @@ async function cleanupHangQuery(

// Nothing to cleanup
if (!killQueryResp || killQueryResp?.rows === 0) {
console.log('[/api/clean] Done, nothing to cleanup')
return {
lastCleanup,
message: 'Nothing to cleanup',
Expand All @@ -108,9 +111,10 @@ async function cleanupHangQuery(
error instanceof Error &&
error.message.includes('Unexpected end of JSON input')
) {
console.log('[/api/clean] Done, nothing to cleanup')
return { lastCleanup, message: 'Nothing to cleanup' }
} else {
console.error(error)
console.error('[/api/clean] Error when killing queries:', error)
throw new Error(`Error when killing queries: ${error}`)
}
}
Expand All @@ -126,7 +130,9 @@ async function cleanupHangQuery(
],
format: 'JSONEachRow',
})
console.log('[/api/clean] LastCleanup event created')
} catch (error) {
console.error("[/api/clean] 'LastCleanup' event creating error:", error)
throw new Error(`'LastCleanup' event creating error: ${error}`)
}

Expand Down

1 comment on commit b46175e

@vercel
Copy link

@vercel vercel bot commented on b46175e Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.