-
Notifications
You must be signed in to change notification settings - Fork 91
Feat/skew protection #3147
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
Feat/skew protection #3147
Conversation
📊 Package size report 0.2%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
bd48131
to
752f755
Compare
752f755
to
47fb69f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally instead of setting this internal Next.js env var, we could set this via next.config.js#deploymentId
( https://github.com/vercel/next.js/blob/bd727d6f19852cc7ffd44b0321fd35b5f88c55e3/packages/next/src/server/config-shared.ts#L1065-L1068 ), but for now we don't have blessed way to mutate config
47fb69f
to
7ba5192
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the case of turning on skew protection, then disabling it in the following deploy, is that possible? Is that something that would ever be done? Currently this setting looks to be scoped to the site level rather than per deploy (like blobs is for example), so unsure of the mechanics here and whether it would take the most recent settings each time or work another way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skew protection is deploy-level configuration / metadata in similar way as redirects/rewrites are. It is possible to turn it off for future deploys by just not producing configuration for it.
This config file will be wiped automatically because it's part of Frameworks API which does have automatic cleanup ( ( https://github.com/netlify/build/blob/main/packages/build/src/plugins_core/pre_cleanup/index.ts ) so we don't have to ensure it doesn't exist here to handle case of turning it on and later turning it off.
Is that something that would ever be done?
I don't see a reason why one would do that, unless bugs / not handled edge cases would be uncovered in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder that you found ntl deploy --upload-source-zip
, not sure if it would help simplify things or not though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would like to try this as follow up. There are potential quirks here that this is CLI version dependent and we have cases of intentionally using older CLI versions (before that option was available). For right now this is used only for this new skew protection tests so it shouldn't cause problems, just potential future annoyance if we try to move other tests to use it as well
...e was written with it instead of inlining it again in test
Uh oh!
There was an error while loading. Please reload this page.
Description
This conditionally enables skew protection. Most magic happens outside of next-runtime. It's not enabled by default. Can be enabled via feature flag or env var.
Some details:
We are providing current DEPLOY_ID via setting
NEXT_DEPLOYMENT_ID
env var, so Next.js build use it when producic static assets (i.e.html
files having<script>
etc tags with appended?dpl=${DEPLOY_ID}
query param, browser bundles attachingX-Deployment-Id
header for server action fetches as well asnext/link
navigation fetches (next/link
has skew protection header "only" since Next 15).Before
next@14.1.4
skew protection was experimental and requires experiments enabled (this was done in e2e test fixture to make sure it works as expected in all routinely tested Next.js versions)Documentation
Added separately to docs
Tests
Added e2e test for skew protection. To make it work I also added some basic setup to use buildbot instead of CLI for deploys as currently CLI deploys can't use skew protection.
Relevant links (GitHub issues, etc.) or a picture of cute animal