Repository navigation
SMOODEV-3805: Keep Buffers intact in the S3 Next cache handler - #13
Merged
Merged
Conversation
JSON.stringify calls Buffer#toJSON before the replacer, so the replacer never
saw a Buffer and APP_ROUTE bodies were stored as { type: 'Buffer', data }. On a
cache hit Next wrote that object as the 15-byte text "[object Object]", which
broke smoo.ai's favicon.ico, opengraph-image and twitter-image. serialize now
reads the raw value off the holder, and deserialize also decodes the old shape
so entries already in S3 serve correctly without a purge. Release 0.2.2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UwsWFhUD6BK9mXkakhUUJ6
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
serializeinsst/src/next/cache-handler.cjsnever base64-encoded a Buffer.JSON.stringifycallsBuffer#toJSONbefore the replacer, so the replacer saw{ type: 'Buffer', data: [...] }andBuffer.isBuffer(v)was always false. APP_ROUTE bodies were stored as plain objects, and on every cache HIT Next wrote them out as the 15-byte text[object Object]. On smoo.ai that breaks/favicon.ico,/opengraph-imageand/twitter-image(link previews and the browser tab icon).Solution
serializereads the raw value off the holder (this[k]), so Buffers become{ __b64 }as intended.deserializealso decodes the old{ type: 'Buffer', data }shape, so entries already in S3 serve correctly without a purge.node --testregression test (in-memory S3) plus a CI step; release 0.2.2.Verification
pnpm test: 2/2 pass with the fix, 0/2 on the old code.isBuffer: false,String(body) === "[object Object]".Jira: SMOODEV-3805
🤖 Generated with Claude Code
https://claude.ai/code/session_01UwsWFhUD6BK9mXkakhUUJ6