chore: improves routeError log safety (#10793)

Improves the logging that `routeError` throws.

Logs were sometimes being swallowed if there was a problem with the
incoming request. Now they will surface.
This commit is contained in:
James Mikrut
2025-01-24 14:06:01 -05:00
committed by GitHub
parent 828b3b71c0
commit ace755742c

View File

@@ -37,6 +37,12 @@ export const routeError = async ({
}
}
let response = formatErrors(err)
let status = err.status || httpStatus.INTERNAL_SERVER_ERROR
logError({ err, payload })
const req = incomingReq as PayloadRequest
req.payload = payload
@@ -47,12 +53,6 @@ export const routeError = async ({
const { config } = payload
let response = formatErrors(err)
let status = err.status || httpStatus.INTERNAL_SERVER_ERROR
logError({ err, payload })
// Internal server errors can contain anything, including potentially sensitive data.
// Therefore, error details will be hidden from the response unless `config.debug` is `true`
if (!config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {