-
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
Changes from all commits
e1e306e
d9913f5
8c60a9c
7bc84ea
e7f67f7
0feb82a
201ca70
76377c3
8d92959
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
feat: Experimental file based service discovery when running multiple Wrangler instances locally. To try it out, make sure all your local Wrangler instances are running with the `--x-registry` flag. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
name = "a" | ||
compatibility_date = "2024-06-10" | ||
|
||
[durable_objects] | ||
bindings = [ | ||
{ name = "MY_DO", class_name = "MyDurableObject" } | ||
] | ||
|
||
[[migrations]] | ||
tag = "v1" | ||
new_classes = ["MyDurableObject"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name = "b" | ||
compatibility_date = "2024-06-10" | ||
|
||
[durable_objects] | ||
bindings = [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name = "c" | ||
compatibility_date = "2024-06-10" | ||
|
||
[durable_objects] | ||
bindings = [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { fork } from "child_process"; | ||
import * as path from "path"; | ||
import { setTimeout } from "timers/promises"; | ||
import { fetch } from "undici"; | ||
import { afterAll, beforeAll, describe, expect, it } from "vitest"; | ||
import { unstable_dev } from "wrangler"; | ||
|
@@ -8,7 +9,7 @@ import type { UnstableDevWorker } from "wrangler"; | |
|
||
// TODO: reenable when https://github.com/cloudflare/workers-sdk/pull/4241 lands | ||
// and improves reliability of this test. | ||
describe.skip( | ||
describe( | ||
"Pages Functions", | ||
() => { | ||
let a: UnstableDevWorker; | ||
|
@@ -26,15 +27,28 @@ describe.skip( | |
beforeAll(async () => { | ||
a = await unstable_dev(path.join(__dirname, "../a/index.ts"), { | ||
config: path.join(__dirname, "../a/wrangler.toml"), | ||
experimental: { | ||
fileBasedRegistry: true, | ||
disableExperimentalWarning: true, | ||
}, | ||
}); | ||
await setTimeout(1000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. Going forward we should add polling or watching to the unstable_dev stuff so that these are no longer needed. |
||
b = await unstable_dev(path.join(__dirname, "../b/index.ts"), { | ||
config: path.join(__dirname, "../b/wrangler.toml"), | ||
experimental: { | ||
fileBasedRegistry: true, | ||
disableExperimentalWarning: true, | ||
}, | ||
}); | ||
|
||
await setTimeout(1000); | ||
c = await unstable_dev(path.join(__dirname, "../c/index.ts"), { | ||
config: path.join(__dirname, "../c/wrangler.toml"), | ||
experimental: { | ||
fileBasedRegistry: true, | ||
disableExperimentalWarning: true, | ||
}, | ||
}); | ||
|
||
await setTimeout(1000); | ||
dWranglerProcess = fork( | ||
path.join( | ||
"..", | ||
|
@@ -48,10 +62,10 @@ describe.skip( | |
[ | ||
"pages", | ||
"dev", | ||
"--x-registry", | ||
"public", | ||
"--compatibility-date=2024-03-04", | ||
"--do=PAGES_REFERENCED_DO=MyDurableObject@a", | ||
"--port=0", | ||
"--inspector-port=0", | ||
], | ||
{ | ||
stdio: ["ignore", "ignore", "ignore", "ipc"], | ||
|
@@ -63,6 +77,7 @@ describe.skip( | |
dPort = parsedMessage.port; | ||
dResolveReadyPromise(undefined); | ||
}); | ||
await setTimeout(1000); | ||
}); | ||
|
||
afterAll(async () => { | ||
|
@@ -85,10 +100,7 @@ describe.skip( | |
|
||
it("connects up Durable Objects and keeps state across wrangler instances", async () => { | ||
await dReadyPromise; | ||
|
||
// Service registry is polled every 300ms, | ||
// so let's give all the Workers a little time to find each other | ||
await new Promise((resolve) => setTimeout(resolve, 700)); | ||
await setTimeout(1000); | ||
|
||
const responseA = await a.fetch(`/`, { | ||
headers: { | ||
|
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.
❤️