-
Notifications
You must be signed in to change notification settings - Fork 49
[Preview] Add support for skew protection #746
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
base: main
Are you sure you want to change the base?
Conversation
|
commit: |
2356748
to
0a6f2dd
Compare
0a6f2dd
to
18ba05a
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 just took a really quick look for now, will make a proper review later
} | ||
|
||
const versionDomain = version.split("-")[0]; | ||
const hostname = `${versionDomain}-${process.env.CF_WORKER_NAME}.${process.env.CF_PREVIEW_DOMAIN}.workers.dev`; |
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 don't think this one will work if people uses durable object, for these cases you could use Cloudflare-Workers-Version-Overrides
headers with the worker binding.
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.
Cloudflare-Workers-Version-Overrides
can only access one of 2 versions in a gradual deployment :(
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 this is looking pretty good on my initial read though. Going to have another look later on as well.
Co-authored-by: James Anderson <[email protected]>
There are 2 main files in this PR:
packages/cloudflare/src/cli/commands/skew-protection.ts
(build time)This builds a mapping from
deploymentId
to the worker version at build time.Note that because the worker you are building has no version yet, "current" is used instead.
packages/cloudflare/src/cli/templates/skew-protection.ts
(runtime)At runtime, if a particular version is requested and it is present in the mapping,
we'll fetch the result from a preview URL with a hostname of
<version>-<worker_name>.<domain>.workers.dev
How to use it:
cloudflare.skewProtectionEnabled
totrue
in your OpenNext configpackages/cloudflare/src/api/cloudflare-context.ts
deployementId
- you can use thegetDeploymentId()
helperTODO: