mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5858] fix(cli): persist cookies across sequential requests in collection runner #5384
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5384
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5858
Author: @FerreiraAdrien
Created: 2/10/2026
Status: 🔄 Open
Base:
main← Head:fix/cli-cookie-persistence📝 Commits (2)
95de811fix(cli): persist cookies across sequential requests in collection runner088d498fix(cli): merge cookie jar with user-specified Cookie header instead of overwriting📊 Changes
7 files changed (+76 additions, -15 deletions)
View changed files
📝
packages/hoppscotch-cli/src/interfaces/response.ts(+2 -0)📝
packages/hoppscotch-cli/src/types/request.ts(+2 -0)📝
packages/hoppscotch-cli/src/utils/collections.ts(+11 -3)📝
packages/hoppscotch-cli/src/utils/hopp-fetch.ts(+2 -2)📝
packages/hoppscotch-cli/src/utils/pre-request.ts(+4 -2)📝
packages/hoppscotch-cli/src/utils/request.ts(+49 -5)📝
packages/hoppscotch-cli/src/utils/test.ts(+6 -3)📄 Description
What's changed
When running
hopp teston a collection,Set-Cookieheaders received from responses (e.g. after a login request) were neither stored nor sent with subsequent requests. This caused endpoints requiring cookie-based authentication to fail with 401.Root cause
requestRunnerused bareaxios()without a cookie jar, and eachcreateHoppFetchHook()call (for pre-request/test scripts) created its own ephemeralCookieJar.Fix A shared
CookieJar(tough-cookie, already a dependency) is created per iteration incollectionsRunnerand propagated through the entire execution chain:collectionsRunner→processCollection→processRequest→{preRequestScriptRunner, requestRunner, getTestScriptParams}→createHoppFetchHookChanges:
utils/hopp-fetch.ts— Accept an optional externalCookieJartypes/request.ts— AddcookieJar?toProcessRequestParamsinterfaces/response.ts— AddcookieJar?toTestScriptParamsutils/request.ts— Inject cookies before requests, storeSet-Cookieafter responses (success & error paths), pass jar throughprocessRequestutils/pre-request.ts— Propagate jar tocreateHoppFetchHookutils/test.ts— Propagate jar tocreateHoppFetchHookutils/collections.ts— Create oneCookieJarper iteration, pass it downNotes to reviewers
?) and appended at the end of signatures — no breaking changes.externalJar ?? new CookieJar()fallback inhopp-fetch.ts,if (cookieJar)guards inrequestRunner).Summary by cubic
Fixes cookie persistence in the CLI collection runner so cookies set by earlier requests are sent with later ones. This enables cookie-based auth flows to work within each collection iteration.
Written for commit
088d498ddb. Summary will update on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.