Skip to content

Conversation

@pieh
Copy link
Contributor

@pieh pieh commented Sep 1, 2023

Description

When working on something else I noticed quite the weirdness with how rsc-data middleware behaves when it comes to routing:

# hitting /blog/erica/first-post
Aug 31, 06:02:32 PM: 01H9659Z info   Is rsc request
Aug 31, 06:02:32 PM: 01H9659Z info   Rewriting to /blog/erica/first-post.rsc
# hitting /blog/erica/first-post/
Aug 31, 06:06:23 PM: 01H965H0 info   Is rsc request
Aug 31, 06:06:23 PM: 01H965H0 info   Rewriting to /blog/erica/first-post.rsc/
# hitting /blog/erica/first-post.rsc
Aug 31, 06:07:18 PM: 01H965JP info   Is rsc request
Aug 31, 06:07:18 PM: 01H965JP info   Rewriting to /blog/erica/first-post.rsc.rsc

as /blog/erica/first-post.rsc is actually asset produced at build time:
image
so only the first request from logs above one worked correctly. Second one did seem to work, but instead of using static asset on CDN it wen't to lambda to generate it and third one I don't even remember but it definitely seems wrong.

I'm not exactly sure why we make edge middleware to handle requests for .rsc paths - when trying that path we should just use path as-is - it will either use static asset from CDN or go to lambda to generate it (and possibly cache with with ODB). I did remove that from this PR as it didn't make sense to me, especially as it was redirecting to /blog/erica/first-post.rsc.rsc which seems all kind of wrong thing to do.

The statically produced .rsc files also didn't get expected text/x-component header (we only get this header right now when request is handled by lambda), so I also added header rule to ensure those get expected headers.

And finally I'm not sure why the rsc-data would want to rewrite to paths that end with trailing slash (.rsc/) - the comment say to differentiate those for ODB, but with no clarity why you want to do that? It also meant that if user hit path with trailing slash it would never use static assets on CDN and would always need to go through lambda

Documentation

Tests

You can test this change yourself like so:

  1. TODO

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

…me, don't use rsc-data edge function when hitting .rsc path directly
@pieh pieh requested a review from a team as a code owner September 1, 2023 10:38
@netlify
Copy link

netlify bot commented Sep 1, 2023

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

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/64f1bf2bc2c07c0008c0f0b6
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

@netlify
Copy link

netlify bot commented Sep 1, 2023

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

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/64f1bf2baff88600086fdad8
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

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

netlify bot commented Sep 1, 2023

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

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/64f1bf2bc00a9800080703c5
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

@netlify
Copy link

netlify bot commented Sep 1, 2023

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

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/64f1bf2bb1b61600086bc598
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

@netlify
Copy link

netlify bot commented Sep 1, 2023

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

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/64f1bf2b120f180008dc81d4
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

@netlify
Copy link

netlify bot commented Sep 1, 2023

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

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/64f1bf2be797ce0008fb6e18
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

@netlify
Copy link

netlify bot commented Sep 1, 2023

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

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo-all-flags/deploys/64f1bf2b120f180008dc81d9
😎 Deploy Preview https://deploy-preview-2290--netlify-plugin-nextjs-demo-all-flags.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 configuration.

@netlify
Copy link

netlify bot commented Sep 1, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/64f1bf2b0d1dd500072ba999
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

@netlify
Copy link

netlify bot commented Sep 1, 2023

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

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/64f1bf2be0a2a60008ae05f3
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

@netlify
Copy link

netlify bot commented Sep 1, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 44e7843
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/64f1bf2bd087980008db10c7
😎 Deploy Preview https://deploy-preview-2290--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 configuration.

@ascorbic
Copy link
Contributor

ascorbic commented Sep 4, 2023

I think the reason was because at the time at least Next didn't request .rsc files directly. We were adding the .rsc to we could either load the static asset, or get a different asset from the ODB as we couldn't vary on the RSC header. I dunno which of those have now changed

@serhalp
Copy link
Member

serhalp commented Jun 4, 2024

Superseded by v5.

@serhalp serhalp closed this Jun 4, 2024
@serhalp serhalp deleted the fix-rsc-data branch June 4, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug code to address defects in shipped code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants