fix: do not report some datalake errors to analytics (#9085)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2025-05-25 16:33:07 +07:00 committed by GitHub
parent 6bd8fff00b
commit 0c8c2cc84e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -233,6 +233,16 @@ export async function createServer (ctx: MeasureContext, config: Config): Promis
app.get('/image/:transform/:workspace/:name', withBlob, wrapRequest(ctx, 'transformImage', handleImageGet)) // no auth
const sendErrorToAnalytics = (err: any): boolean => {
const ignoreMessages = [
'Unexpected end of form', // happens when the client closes the connection before the upload is complete
'Premature close', // happens when the client closes the connection before the upload is complete
'File too large' // happens when the file exceeds the limit set by express-fileupload
]
return !ignoreMessages.includes(err.message)
}
app.use((err: any, _req: any, res: any, _next: any) => {
ctx.error(err.message, { code: err.code, message: err.message })
if (err instanceof ApiError) {
@ -240,7 +250,11 @@ export async function createServer (ctx: MeasureContext, config: Config): Promis
return
}
Analytics.handleError(err)
// do not send some errors to analytics
if (sendErrorToAnalytics(err)) {
Analytics.handleError(err)
}
res.status(500).json({ message: err.message?.length > 0 ? err.message : 'Internal Server Error' })
})