fix: forward cookies from 4XX/5XX responses in runner and CLI (#7498)

When axios receives a 4XX/5XX response it throws an error, causing
execution to jump to the catch block. saveCookies() was only called
in the try block (2XX path), so error-status cookies were silently
dropped in collection runs.

Fix applied to both affected code paths:
- packages/bruno-cli/src/runner/run-single-request.js (CLI runner)
- packages/bruno-electron/src/ipc/network/index.js (app collection runner)

Manual single-request execution was already correct — saveCookies() is
called after the try/catch there, so both status paths were covered.

Fixes #7475
This commit is contained in:
Abhishek S Lal
2026-04-01 21:24:32 +05:30
committed by GitHub
parent 8e978ae305
commit c8abb5be16
2 changed files with 10 additions and 0 deletions

View File

@@ -684,6 +684,11 @@ const runSingleRequest = async function (
// Prevents the duration on leaking to the actual result
responseTime = response.headers.get('request-duration');
response.headers.delete('request-duration');
// save cookies if enabled (4XX/5XX responses can also set cookies)
if (!options.disableCookies) {
saveCookies(request.url, response.headers);
}
} else {
console.log(chalk.red(stripExtension(relativeItemPathname)) + chalk.dim(` (${err.message})`));
return {

View File

@@ -1660,6 +1660,11 @@ const registerNetworkIpc = (mainWindow) => {
error.response.data = data;
error.response.dataBuffer = dataBuffer;
// save cookies (4XX/5XX responses can also set cookies)
if (preferencesUtil.shouldStoreCookies()) {
saveCookies(request.url, error.response.headers);
}
timeEnd = Date.now();
response = {
status: error.response.status,