mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user