Skip to content

test: added tests to check that the vary header contains 'RSC' #1993

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

Merged
merged 9 commits into from
Mar 23, 2023

Conversation

nickytonline
Copy link

@nickytonline nickytonline commented Mar 15, 2023

Summary

Fixes an issue where requests coming in to the edge function that were handling React Server Components were always returning the first cached response causing issues with serving the content type text/html or application/octet-stream

It looks like the vary header is already in the response, so I've added tests to ensure it remains.

Closes https://github.com/netlify/pod-ecosystem-frameworks/issues/352

Test plan

There is an end-to-end test in this PR that tests that this works, but you can also curl the deploy preview to see it working.

  1. Run curl -v https://deploy-preview-1993--netlify-plugin-nextjs-demo.netlify.app/blog/erica/. The content type returned is content-type: text/html; charset=utf-8
  2. Run curl -v -H "RSC: 1" https://deploy-preview-1993--netlify-plugin-nextjs-demo.netlify.app/blog/erica/, The content type returned is content-type: application/octet-stream

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/641c29a6e7259400071a66fd
😎 Deploy Preview https://deploy-preview-1993--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/641c29a6b92a6100082535b0
😎 Deploy Preview https://deploy-preview-1993--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/641c29a6c441ea0008936767
😎 Deploy Preview https://deploy-preview-1993--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/641c29a73e50a50008b0c320
😎 Deploy Preview https://deploy-preview-1993--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/641c29a61e531b0008f3dbde
😎 Deploy Preview https://deploy-preview-1993--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Mar 15, 2023
@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/641c29a6fa16f000084f8d15
😎 Deploy Preview https://deploy-preview-1993--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@nickytonline nickytonline self-assigned this Mar 15, 2023
@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/641c29a65581200008658495
😎 Deploy Preview https://deploy-preview-1993--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/641c29a624fe640008cde237
😎 Deploy Preview https://deploy-preview-1993--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 15, 2023

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit c5ed774
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/641c29a6e7259400071a6702
😎 Deploy Preview https://deploy-preview-1993--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@nickytonline nickytonline force-pushed the nickytonline/use-vary-header-for-rsc branch 2 times, most recently from 331a956 to ae79440 Compare March 15, 2023 23:19
@nickytonline nickytonline marked this pull request as ready for review March 15, 2023 23:47
@nickytonline nickytonline requested a review from a team March 15, 2023 23:47
@nickytonline nickytonline force-pushed the nickytonline/use-vary-header-for-rsc branch from 513d23e to 660afd5 Compare March 15, 2023 23:47
@nickytonline nickytonline force-pushed the nickytonline/use-vary-header-for-rsc branch from 660afd5 to 958fb89 Compare March 15, 2023 23:51
@nickytonline nickytonline force-pushed the nickytonline/use-vary-header-for-rsc branch from 9073caf to 2620db5 Compare March 16, 2023 11:30
sarahetter
sarahetter previously approved these changes Mar 16, 2023
taty2010
taty2010 previously approved these changes Mar 16, 2023

// Set the 'vary' header to 'RSC' to ensure that we cache correctly for the different
// possible content-types: application/octet-stream and text/html
request.headers.set('vary', 'RSC')
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be on the Response?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, you're right. Not sure why I put it on the request (late night coding 🙃 ), and also not sure why my tests and curls pass. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

It already worked. The problem isn't it returning the wrong data - that was already fixed. The problem is the browser caching the wrong data. The tests should be checking that the server is returning the Vary header, and you can manually test it in the browser with the instructions in https://github.com/netlify/pod-ecosystem-frameworks/issues/352

Copy link
Author

Choose a reason for hiding this comment

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

I've added tests to check for the vary header. Oddly enough, it looks like the vary header is working already. I removed my change and just updated tests.

@nickytonline nickytonline changed the title fix: added a vary header with RSC to get proper content-type test: added tests to check that the vary header contains 'RSC' Mar 17, 2023
@github-actions github-actions bot added the type: chore work needed to keep the product and development running smoothly label Mar 17, 2023
@nickytonline nickytonline removed the type: bug code to address defects in shipped code label Mar 17, 2023
@nickytonline nickytonline dismissed stale reviews from sarahetter and taty2010 March 22, 2023 13:26

scope of the PR changed. It's only tests now.

@nickytonline nickytonline requested a review from a team March 22, 2023 13:26
@nickytonline nickytonline merged commit 124d4ae into main Mar 23, 2023
@nickytonline nickytonline deleted the nickytonline/use-vary-header-for-rsc branch March 23, 2023 19:26
nickytonline added a commit that referenced this pull request Apr 4, 2023
nickytonline added a commit that referenced this pull request Apr 4, 2023
nickytonline added a commit that referenced this pull request Apr 4, 2023
nickytonline added a commit that referenced this pull request Apr 4, 2023
kodiakhq bot pushed a commit that referenced this pull request Apr 4, 2023
* Revert "test: added tests to check that the vary header contains 'RSC' (#1993)"

This reverts commit 124d4ae.

* Revert "Revert "test: added tests to check that the vary header contains 'RSC' (#1993)""

This reverts commit 4731be5.

* test: skipping vary header test for rsc for now until issue is fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore work needed to keep the product and development running smoothly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants