-
Notifications
You must be signed in to change notification settings - Fork 688
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
File based dev registry #5214
File based dev registry #5214
Conversation
🦋 Changeset detectedLatest commit: 8d92959 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9585443653/npm-package-wrangler-5214 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/5214/npm-package-wrangler-5214 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9585443653/npm-package-wrangler-5214 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9585443653/npm-package-create-cloudflare-5214 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9585443653/npm-package-cloudflare-kv-asset-handler-5214 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9585443653/npm-package-miniflare-5214 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9585443653/npm-package-cloudflare-pages-shared-5214 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/9585443653/npm-package-cloudflare-vitest-pool-workers-5214 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
|
dd3e0ce
to
d9913f5
Compare
.option("experimental-registry", { | ||
alias: ["x-registry"], |
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.
👏
export const run = <V>(flagValues: ExperimentalFlags, cb: () => V) => | ||
flags.run(flagValues, cb); | ||
|
||
export const FILE_BASED_REGISTRY = () => flags.getStore()?.FILE_BASED_REGISTRY; | ||
|
||
// TODO: actually use this | ||
export const DEV_ENV = () => flags.getStore()?.DEV_ENV; |
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.
Can we discuss alternatives to this interface please?
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.
Absolutely—what are your concerns?
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.
Minor point about interface:
I'd like to make adding a feature flag as easy as adding it to a type with no repetition. Having an exported function per flag requires multiple changes to this file to add each flag. While this allows us to find all usages of each feature flag with Find All References, they won't be easy to find usages of any flag. Can we try something like export const XFLAG = <F extends keyof ExperimentalFlags>(flag: F) => ExperimentalFlags[F];
?
More for discussion:
This is a great use of AsyncLocalStorage. Can we generalise this use for other singletons like Logger etc? Are there any parts of wrangler this wouldn't work for?
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.
Didn't have time to review it. But I see that @RamIdeas has approved.
@@ -27,8 +27,7 @@ describe("'wrangler dev' correctly renders pages", () => { | |||
expect((content as Record<string, object>).run).toEqual("function"); | |||
}); | |||
|
|||
// TODO: unskip when https://github.com/cloudflare/workerd/pull/2095 is merged and released | |||
it.skip("ai binding properties", async ({ expect }) => { |
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.
❤️
}); | ||
await setTimeout(1000); |
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.
Why the need for these pauses? If this is a shortcoming in the file-based reg approach, perhaps it is not ideal?
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.
Discussed offline. This is a limitation to how unstable_dev works right now, not related to this refactor.
The problem is that unstable_dev will only read the dev-registry once, rather than polling it for changes.
So we need to make sure that upstream workers are in-place and ready before starting downstream workers.
The wrangler dev
command does do polling, so does not have this problem. So normal users would not need such pauses.
Going forward we should add polling or watching to the unstable_dev stuff so that these are no longer needed.
What this PR solves / how to test
Fixes #6037
Author has addressed the following