Skip to content

Enable iron-session cookie chunking for go sessions - #943

Merged
xendk merged 1 commit into
developfrom
iron-session-chunking
Jun 10, 2026
Merged

Enable iron-session cookie chunking for go sessions#943
xendk merged 1 commit into
developfrom
iron-session-chunking

Conversation

@kasperg

@kasperg kasperg commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Link to issue

https://reload.atlassian.net/browse/DDF-348

Description

The go-session cookie holds two JWTs (access + refresh) plus PKCE and profile fields, and we are hitting the 4 KB per-cookie browser limit for some users. Iron-session 8.0.4 has no built-in workaround and the upstream fix is unreviewed (vvo/iron-session#937).

Apply that PR as a patch-package patch against an exact-pinned iron-session@8.0.4 so chunking is available without forking, and enable it in getSessionOptions. With chunking on, iron-session keeps a single go-session cookie when the sealed value fits, and otherwise splits it into go-session.0, go-session.1, ... transparently on read.

Letting CI fail on a future Dependabot bump is the intended signal to refresh or drop the patch when upstream merges.

To reproduce the patch file (iron-session ships only compiled dist/*, so we cannot patch the source files referenced by PR #937 directly):

# 1. Get the iron-session source at v8.0.4 with PR #937 applied.
git clone https://github.com/vvo/iron-session.git
cd iron-session
git fetch origin pull/937/head:pr-937
git diff v8.0.4..pr-937 -- src/core.ts > /tmp/pr-937-core.diff
git checkout v8.0.4
git apply /tmp/pr-937-core.diff

# 2. Build dist/* with the upstream toolchain.
npm install --ignore-scripts
npx tsup

# 3. Copy the built dist into this project's node_modules and let
#    patch-package capture the diff against the published 8.0.4.
cp dist/* <dpl-web>/go/node_modules/iron-session/dist/
cd <dpl-web>/go
npx patch-package iron-session

This keeps the committed patch bit-for-bit faithful to what upstream would publish if PR #937 merged, rather than hand-translating TypeScript changes into compiled output.

Assisted-by: Claude noreply@anthropic.com

The go-session cookie holds two JWTs (access + refresh) plus PKCE and
profile fields, and we are hitting the 4 KB per-cookie browser limit for
some users. Iron-session 8.0.4 has no built-in workaround and the
upstream fix is unreviewed (vvo/iron-session#937).

Apply that PR as a patch-package patch against an exact-pinned
iron-session@8.0.4 so chunking is available without forking, and enable
it in getSessionOptions. With chunking on, iron-session keeps a single
go-session cookie when the sealed value fits, and otherwise splits it
into go-session.0, go-session.1, ... transparently on read.

Letting CI fail on a future Dependabot bump is the intended signal to
refresh or drop the patch when upstream merges.

To reproduce the patch file (iron-session ships only compiled dist/*,
so we cannot patch the source files referenced by PR #937 directly):

    # 1. Get the iron-session source at v8.0.4 with PR #937 applied.
    git clone https://github.com/vvo/iron-session.git
    cd iron-session
    git fetch origin pull/937/head:pr-937
    git diff v8.0.4..pr-937 -- src/core.ts > /tmp/pr-937-core.diff
    git checkout v8.0.4
    git apply /tmp/pr-937-core.diff

    # 2. Build dist/* with the upstream toolchain.
    npm install --ignore-scripts
    npx tsup

    # 3. Copy the built dist into this project's node_modules and let
    #    patch-package capture the diff against the published 8.0.4.
    cp dist/* <dpl-web>/go/node_modules/iron-session/dist/
    cd <dpl-web>/go
    npx patch-package iron-session

This keeps the committed patch bit-for-bit faithful to what upstream
would publish if PR #937 merged, rather than hand-translating
TypeScript changes into compiled output.

Assisted-by: Claude <noreply@anthropic.com>

@ThomasGross ThomasGross left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@xendk
xendk merged commit c1c008f into develop Jun 10, 2026
51 checks passed
@xendk
xendk deleted the iron-session-chunking branch June 10, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants