Skip to content

Fix mutation of cache objects causing base64 responses#173

Merged
AyronK merged 1 commit intofortedigital:masterfrom
m-sanders:next16-base64-fs-fallbacks
Dec 8, 2025
Merged

Fix mutation of cache objects causing base64 responses#173
AyronK merged 1 commit intofortedigital:masterfrom
m-sanders:next16-base64-fs-fallbacks

Conversation

@m-sanders
Copy link
Copy Markdown
Contributor

@m-sanders m-sanders commented Dec 4, 2025

Redis handler mutated the original cacheHandlerValue object Next.js uses for responses. When parseBuffersToStrings() converted Buffers to base64, Next.js sent the mutated object to users. We shallow clone value object before mutation to isolate changes from Next.js's reference.

How was this tested?

Manually

$ npm run build && npm run start
$ redis-cli -p 6379 -n 1 -e flushdb
$ curl http://localhost:3000/manifest.webmanifest
{"name":"Next.js App","short_name":"Next.js App","description":"Next.js App","start_url":"/","display":"standalone","background_color":"#fff","theme_color":"#fff","icons":[{"src":"/favicon.ico","sizes":"any","type":"image/x-icon"}]}%

@m-sanders m-sanders marked this pull request as ready for review December 4, 2025 15:41
@m-sanders m-sanders marked this pull request as draft December 4, 2025 15:42
@m-sanders m-sanders marked this pull request as ready for review December 4, 2025 15:45
@m-sanders m-sanders changed the base branch from next16 to master December 5, 2025 12:53
Redis handler mutated the original `cacheHandlerValue` object Next.js uses for responses. When `parseBuffersToStrings()` converted Buffers to base64, Next.js sent the mutated object to users. So we clone value object before mutation to isolate changes from Next.js's reference.
@m-sanders m-sanders force-pushed the next16-base64-fs-fallbacks branch from ec7f298 to a3599bb Compare December 5, 2025 12:54
@m-sanders
Copy link
Copy Markdown
Contributor Author

@AyronK this is also a bug in Next.js 15.x. Can we get this released please?

@AyronK
Copy link
Copy Markdown
Collaborator

AyronK commented Dec 8, 2025

@m-sanders I will take a look today, thank you.

@AyronK AyronK self-requested a review December 8, 2025 08:25
Copy link
Copy Markdown
Collaborator

@AyronK AyronK left a comment

Choose a reason for hiding this comment

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

lgtm

@AyronK AyronK merged commit 3326115 into fortedigital:master Dec 8, 2025
1 check passed
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.

2 participants