Skip to content

fix(http): identify cookies by name, domain and path - #10471

Merged
tim-smart merged 7 commits into
Effect-TS:v4/next-minorfrom
jpowersdev:fix/cookies-identity
Nov 9, 2026
Merged

tim-smart merged 7 commits into
Effect-TS:v4/next-minorfrom
jpowersdev:fix/cookies-identity

Conversation

@jpowersdev

@jpowersdev jpowersdev commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cookies was keyed by cookie name only, so adding a cookie replaced any earlier cookie with that name even when its Domain or Path differed. RFC 6265 §5.3 identifies a cookie by name, domain and path, and browsers keep both.

  • HttpClientResponse.cookies kept only the last Set-Cookie per name, so HttpClient.withCookiesRef never stored the others.
  • HttpServerResponse.setCookie and expireCookie could not set or expire one name for two scopes in the same response, and fromWeb dropped them when proxying.

Cookies now identifies cookies by name, domain (ignoring a leading dot and letter case) and path everywhere. Cookies.cookies is an ordered ReadonlyArray<Cookie>: adding a cookie removes the one with the same identity and appends the new one, so the array is in last-set order. get, getValue, toRecord and toCookieHeader use the cookie set last for a name; toSetCookieHeaders and mergeIntoArray use every cookie in order. remove(name) drops every scope of the name.

This is the breaking alternative to #10470, which keeps the name-based API and only stops fromSetCookie from dropping cookies.

Breaking changes

Cookies is @stability unstable, so the changeset is minor.

  • Cookies.cookies changes from a name-keyed record to ReadonlyArray<Cookie>, and the Schema.Cookies isomorphic encoding changes from Record(String, Cookie) to Array(Cookie). Code reading cookies.cookies[name] stops compiling; use Cookies.get or Cookies.getValue. fromReadonlyRecord remains as fromIterable(Object.values(record)).
  • Every Cookies constructor and combinator that adds a cookie, such as fromIterable, setCookie, set, setAll, expireCookie and merge, and the HttpServerResponse cookie helpers, replace an existing cookie only when its name, domain and path match. A missing path is distinct from path: "/" because the default path depends on the request URL, so expireCookie("session") after setCookie("session", v, { path: "/" }) now sends both headers instead of only the expiry.

Validation

  • pnpm test --run packages/effect/test/http packages/effect/test/schema packages/platform/node/test/HttpApi.test.ts packages/platform/node/test/NodeHttpServer.test.ts packages/platform/browser/test/BrowserHttpClient.test.ts: 3945 passed, 1 skipped
  • pnpm check, pnpm check-tsc, pnpm lint, pnpm jsdocs --check

Closes #10469

Closes EFF-3508

Closes EFF-3506

@changeset-bot

changeset-bot Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a1995d2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
effect Minor
@effect/opentelemetry Minor
@effect/vitest Minor
@effect/ai-anthropic Minor
@effect/ai-cloudflare Minor
@effect/ai-openai-compat Minor
@effect/ai-openai Minor
@effect/ai-openrouter Minor
@effect/ai-typesafe Minor
@effect/atom-react Minor
@effect/atom-solid Minor
@effect/atom-vue Minor
@effect/platform-browser Minor
@effect/platform-bun Minor
@effect/platform-deno Minor
@effect/platform-node-shared Minor
@effect/platform-node Minor
@effect/sql-clickhouse Minor
@effect/sql-d1 Minor
@effect/sql-libsql Minor
@effect/sql-mssql Minor
@effect/sql-mysql2 Minor
@effect/sql-pg Minor
@effect/sql-pglite Minor
@effect/sql-sqlite-bun Minor
@effect/sql-sqlite-do Minor
@effect/sql-sqlite-node Minor
@effect/sql-sqlite-react-native Minor
@effect/sql-sqlite-wasm Minor
@effect/docgen Minor
@effect/doctest Minor
@effect/graphql-generator Minor
@effect/openapi-generator Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.71 KB 39.71 KB 0.00 KB (0.00%)
basic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
batching.ts 11.29 KB 11.29 KB 0.00 KB (0.00%)
brand.ts 7.00 KB 7.00 KB 0.00 KB (0.00%)
cache.ts 11.83 KB 11.83 KB 0.00 KB (0.00%)
config.ts 23.16 KB 23.16 KB 0.00 KB (0.00%)
differ.ts 22.30 KB 22.30 KB 0.00 KB (0.00%)
http-client.ts 27.51 KB 27.43 KB +0.08 KB (+0.30%)
http-router.ts 37.23 KB 37.30 KB -0.07 KB (-0.19%)
logger.ts 12.28 KB 12.28 KB 0.00 KB (0.00%)
metric.ts 9.74 KB 9.74 KB 0.00 KB (0.00%)
optic.ts 7.21 KB 7.21 KB 0.00 KB (0.00%)
pubsub.ts 16.34 KB 16.34 KB 0.00 KB (0.00%)
queue.ts 13.20 KB 13.20 KB 0.00 KB (0.00%)
schedule.ts 12.07 KB 12.07 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.33 KB 14.33 KB 0.00 KB (0.00%)
schema-binary.ts 42.48 KB 42.48 KB 0.00 KB (0.00%)
schema-class.ts 22.05 KB 22.05 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.00 KB 30.00 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.32 KB 28.32 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.64 KB 15.64 KB 0.00 KB (0.00%)
schema-string.ts 12.53 KB 12.53 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.51 KB 16.51 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.26 KB 39.26 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 26.46 KB 26.46 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.21 KB 21.21 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.38 KB 21.38 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.47 KB 21.47 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.47 KB 26.47 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.54 KB 21.54 KB 0.00 KB (0.00%)
schema.ts 21.14 KB 21.14 KB 0.00 KB (0.00%)
stm.ts 14.50 KB 14.50 KB 0.00 KB (0.00%)
stream.ts 10.66 KB 10.66 KB 0.00 KB (0.00%)
supervisor.ts 11.61 KB 11.61 KB 0.00 KB (0.00%)

@effect-bot
effect-bot force-pushed the fix/cookies-identity branch from 716c06f to 8ba73dc Compare November 9, 2026 00:08
@effect-bot
effect-bot marked this pull request as ready for review November 9, 2026 00:08
@tim-smart
tim-smart merged commit d0c49be into Effect-TS:v4/next-minor Nov 9, 2026
14 checks passed
tim-smart pushed a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 16, 2026
effect-bot added a commit that referenced this pull request Nov 17, 2026
effect-bot added a commit that referenced this pull request Nov 17, 2026
effect-bot added a commit that referenced this pull request Nov 17, 2026
effect-bot added a commit that referenced this pull request Nov 17, 2026
effect-bot added a commit that referenced this pull request Nov 17, 2026
effect-bot added a commit that referenced this pull request Nov 20, 2026
effect-bot added a commit that referenced this pull request Nov 20, 2026
effect-bot added a commit that referenced this pull request Nov 20, 2026
effect-bot added a commit that referenced this pull request Nov 20, 2026
effect-bot added a commit that referenced this pull request Nov 20, 2026
effect-bot added a commit that referenced this pull request Nov 20, 2026
effect-bot added a commit that referenced this pull request Nov 22, 2026
effect-bot added a commit that referenced this pull request Nov 22, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 23, 2026
effect-bot added a commit that referenced this pull request Nov 24, 2026
effect-bot added a commit that referenced this pull request Nov 24, 2026
effect-bot added a commit that referenced this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cookies drops same-name cookies set for a different domain or path

3 participants