Skip to content

Conversation

@schalterDev
Copy link
Contributor

I am running next.js 16 and getting an error for segmentData after getting the cache:

TypeError: p.segmentData.get is not a function

Debug-Logs showing this when setting the cache:

RedisStringsHandler.set() will set the following serializedCacheEntry
...
segmentData: Map(10) {
    '/_tree' => <Buffer 3a 48 4c 5b 22 2f 5f 6e 65 78 74 2f 73 74 61 74 69 63 2f 63 68 75 6e 6b 73 2f 31 64 38 64 61 38 63 30 63 62 66 33 61 37 35 37 2e 63 73 73 22 2c 22 73 ... 1052 more bytes>,
    '/_full' => <Buffer 31 3a 22 24 53 72 65 61 63 74 2e 66 72 61 67 6d 65 6e 74 22 0a 32 3a 49 5b 33 33 39 37 35 36 2c 5b 22 2f 5f 6e 65 78 74 2f 73 74 61 74 69 63 2f 63 68 ... 153653 more bytes>,
  ...
  }
...

segmentData is a Map<string,Buffer> and when serializing this, it becomes an empty object {}.

This PR fixes this by converting buffer into string and back.

@JannikZed
Copy link
Contributor

@schalterDev in general, we did not yet test / start to work on Next.js 16. Im actually expecting more changes than just this one fix here. What did you test already? Does the handler work for the new cache model ? Could you share some insights on what you already tested? That would already be very helpful 🙏🏻

@schalterDev
Copy link
Contributor Author

@JannikZed I haven't systematically tested Next.js 16. I updated our application to version 16 and have only discovered this failure so far. However, we don't use all of Next.js's cache functions.

  • data-cache: fetch with custom tags
  • revalidateTag
  • Full Route Cache: Prerender content pages

I also updated the integration tests of this repo to use Next.js 16 and they run without problems: https://github.com/schalterDev/nextjs-turbo-redis-cache/tree/next-16

I will continue researching and report or fix any errors I encounter. Thank you for your work so far, it is very helpful!

What do you think about this PR? Can it be merged and a new version be released? This would help me to deploy our app on a test environment for better testing / observation.

@JannikZed
Copy link
Contributor

thanks! What is important to understand with next.js 16 is this here:

so cache components are not used / tested in your integration tests. So I would also suggest to accept your current PR as preparation for next.js 16 and start to work on fully tested compatibility in a separate PR.

@JannikZed JannikZed requested a review from tilman November 23, 2025 18:45
Copy link
Contributor

@tilman tilman left a comment

Choose a reason for hiding this comment

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

LGTM

@tilman
Copy link
Contributor

tilman commented Nov 24, 2025

All tests have passed. Only upload of coverage report seem to fail due to lack of permissions for PRs from external repos

@tilman tilman merged commit 5ea9af2 into trieb-work:main Nov 24, 2025
1 of 7 checks passed
@github-actions
Copy link

🎉 This PR is included in version 1.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants