diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/ClientCredentials/index.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/ClientCredentials/index.js index 16df7ca7c..72548d6a0 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/ClientCredentials/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/ClientCredentials/index.js @@ -1,4 +1,4 @@ -import React, { useRef, forwardRef, useState } from 'react'; +import React, { useRef, forwardRef, useState, useMemo } from 'react'; import get from 'lodash/get'; import { useTheme } from 'providers/Theme'; import { useDispatch } from 'react-redux'; diff --git a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/PasswordCredentials/index.js b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/PasswordCredentials/index.js index 7482b6d38..68ae2cc50 100644 --- a/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/PasswordCredentials/index.js +++ b/packages/bruno-app/src/components/RequestPane/Auth/OAuth2/PasswordCredentials/index.js @@ -1,4 +1,4 @@ -import React, { useRef, forwardRef, useState } from 'react'; +import React, { useRef, forwardRef, useState, useMemo } from 'react'; import get from 'lodash/get'; import { useTheme } from 'providers/Theme'; import { useDispatch } from 'react-redux'; diff --git a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js index 954051253..349efbf06 100644 --- a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js +++ b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js @@ -13,7 +13,7 @@ import { useTheme } from 'providers/Theme/index'; import { getEncoding, prettifyJson, uuid } from 'utils/common/index'; const formatResponse = (data, dataBuffer, encoding, mode, filter) => { - if (data === undefined || !dataBuffer) { + if (data === undefined || !dataBuffer || !mode) { return ''; } @@ -91,7 +91,7 @@ const QueryResult = ({ item, collection, data, dataBuffer, width, disableRunEven // Always show raw const allowedPreviewModes = [{ mode: 'raw', name: 'Raw', uid: uuid() }]; - if (!mode) return; + if (!mode || !contentType) return; if (mode?.includes('html') && typeof data === 'string') { allowedPreviewModes.unshift({ mode: 'preview-web', name: 'Web', uid: uuid() }); diff --git a/packages/bruno-electron/src/ipc/network/axios-instance.js b/packages/bruno-electron/src/ipc/network/axios-instance.js index 3f605e170..61c7320ba 100644 --- a/packages/bruno-electron/src/ipc/network/axios-instance.js +++ b/packages/bruno-electron/src/ipc/network/axios-instance.js @@ -238,28 +238,26 @@ function makeAxiosInstance({ const duration = end - metadata.startTime; if (error.response && redirectResponseCodes.includes(error.response.status)) { + metadata.timeline.push({ + timestamp: new Date(), + type: 'response', + message: `HTTP/${error.response.httpVersion || '1.1'} ${error.response.status} ${error.response.statusText}`, + }); + Object.entries(error.response.headers).forEach(([key, value]) => { + metadata.timeline.push({ + timestamp: new Date(), + type: 'responseHeader', + message: `${key}: ${value}`, + }); + }); + metadata.timeline.push({ + timestamp: new Date(), + type: 'info', + message: `Request completed in ${duration} ms`, + }); - - metadata.timeline.push({ - timestamp: new Date(), - type: 'response', - message: `HTTP/${error.response.httpVersion || '1.1'} ${error.response.status} ${error.response.statusText}`, - }); - Object.entries(error.response.headers).forEach(([key, value]) => { - metadata.timeline.push({ - timestamp: new Date(), - type: 'responseHeader', - message: `${key}: ${value}`, - }); - }); - metadata.timeline.push({ - timestamp: new Date(), - type: 'info', - message: `Request completed in ${duration} ms`, - }); - - // Attach the timeline to the response - error.response.timeline = metadata.timeline; + // Attach the timeline to the response + error.response.timeline = metadata.timeline; if (redirectCount >= requestMaxRedirects) { const dataBuffer = Buffer.from(error.response.data); @@ -271,7 +269,8 @@ function makeAxiosInstance({ data: error.response.data, dataBuffer: dataBuffer.toString('base64'), size: Buffer.byteLength(dataBuffer), - duration: error.response.headers.get('request-duration') ?? 0 + duration: error.response.headers.get('request-duration') ?? 0, + timeline: error.response.timeline }; } @@ -313,7 +312,6 @@ function makeAxiosInstance({ } } - setupProxyAgents({ requestConfig, proxyMode, @@ -329,10 +327,10 @@ function makeAxiosInstance({ } else if (error?.code) { let metadata = error?.config?.metadata; - metadata.timeline.push({ + metadata?.timeline?.push({ timestamp: new Date(), type: 'error', - message: safeStringifyJSON(error?.errors) + message: `${safeStringifyJSON(error?.cause) || ''}\n${safeStringifyJSON(error?.errors) || ''}` }); return { status: '-',