Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSC requests fail #733

Open
SystemDisc opened this issue Sep 4, 2024 · 3 comments
Open

RSC requests fail #733

SystemDisc opened this issue Sep 4, 2024 · 3 comments
Labels
bug Something isn't working next15 Waiting for Next.js 15

Comments

@SystemDisc
Copy link

Brief Description of the Bug
rscData does not serialize/deserialize properly since it is a JS Buffer object

Severity
Major

Frequency of Occurrence
Always

Steps to Reproduce
Provide detailed steps to reproduce the behavior, including any specific conditions or configurations where the bug occurs:

  1. Implement SSG and ISR in Next 14+
  2. Implement @neshca/cache-handler/redis-stack
  3. Notice that RSC requests fail due to streams not being created because rscData gets deserialized as a
    { type: 'Buffer', data: [ /* byte array */ ] }

Note: When I updated the implementation to set value.rscData = Buffer.from(value.rscData.data) the problem was resolved. However, the rss of my node process starting to increase over time, indicating a memory leak. I'm not sure why the Buffers don't get released.

Expected vs. Actual Behavior
I expect an out-of-the box implementation to handle RSC requests and caching

Screenshots/Logs
Let me know if this report is not clear enough and I can provide logs and whatnot.

Environment:

  • OS: client is macOS using Chrome, server is Ubuntu 22.x LTS using Node 20.x LTS
  • Node.js version: v20.17.0
  • @neshca/cache-handler version: 1.6.1
  • next version: 15.0.0-canary

Attempted Solutions or Workarounds
value.rscData = Buffer.from(value.rscData.data) which works. However, there seems to be a memory leak caused by the Buffer objects not being released.

Impact of the Bug
RSC requests fail with HTTP 500

@SystemDisc SystemDisc added the bug Something isn't working label Sep 4, 2024
@SystemDisc
Copy link
Author

Attached is a real-world example. However, this particular example does not use a barebones @neshca/cache-handler/redis-stack handler.

:sermon:when-words-are-not-enough:1446553.json

@SystemDisc
Copy link
Author

The best option in my testing so far seems to be:

/**
 * @param {string} key - The cache key.
 * @param {object} cacheHandlerValue - The value to cache.
 * @returns {Promise<void>}
 */
set: async (key, cacheHandlerValue) => {
  if (cacheHandlerValue?.value?.rscData) {
    cacheHandlerValue.value.rscData =
      cacheHandlerValue.value.rscData.toString('utf8');
  }
  // ...
}

@better-salmon
Copy link
Contributor

Hey there, @SystemDisc! Next.js 15 isn't supported yet. Check out discussion #691 for a more reliable workaround.

@better-salmon better-salmon added the next15 Waiting for Next.js 15 label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next15 Waiting for Next.js 15
Projects
None yet
Development

No branches or pull requests

2 participants