From 923b38f24bf375f3a08be7d9facdb0dd3748c694 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 3 Jan 2022 12:05:23 +0530 Subject: [PATCH] chore: more descriptive logging --- src/LegacySocket/socket.ts | 2 +- src/Utils/messages-media.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/LegacySocket/socket.ts b/src/LegacySocket/socket.ts index 7cb9ccf..b101027 100644 --- a/src/LegacySocket/socket.ts +++ b/src/LegacySocket/socket.ts @@ -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 diff --git a/src/Utils/messages-media.ts b/src/Utils/messages-media.ts index 291e4c7..dbb78ff 100644 --- a/src/Utils/messages-media.ts +++ b/src/Utils/messages-media.ts @@ -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) {