chore: more descriptive logging

This commit is contained in:
Adhiraj Singh
2022-01-03 12:05:23 +05:30
parent 3ad02f0317
commit 923b38f24b
2 changed files with 5 additions and 4 deletions

View File

@@ -285,7 +285,7 @@ export const makeSocket = ({
const message = STATUS_CODES[responseStatusCode] || 'unknown'
throw new Boom(
`Unexpected status in '${Array.isArray(json) ? json[0] : (json?.tag || 'query')}': ${message}(${responseStatusCode})`,
{ data: { query: json, message }, statusCode: response.status }
{ data: { query: json, response }, statusCode: response.status }
)
}
return response

View File

@@ -471,9 +471,9 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger }: C
for (let hostname of hosts) {
const auth = encodeURIComponent(uploadInfo.auth) // the auth token
const url = `https://${hostname}${MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`
let result: any
try {
const {data: result} = await axios.post(
const body = await axios.post(
url,
stream,
{
@@ -488,6 +488,7 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger }: C
maxContentLength: Infinity,
}
)
result = body.data
if(result?.url || result?.directPath) {
urls = {
@@ -501,7 +502,7 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger }: C
}
} catch (error) {
const isLast = hostname === hosts[uploadInfo.hosts.length-1]
logger.debug({ trace: error.stack }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`)
logger.debug({ trace: error.stack, uploadResult: result }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`)
}
}
if (!urls) {