Skip to content

Commit

Permalink
Remove Server Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
penalosa committed Jan 8, 2025
1 parent f5bd6a7 commit 79bf518
Show file tree
Hide file tree
Showing 18 changed files with 620 additions and 2,208 deletions.
1 change: 0 additions & 1 deletion fixtures/get-platform-proxy/tests/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ export function getPlatformProxy<T>(
return originalGetPlatformProxy({
...options,
persist: false,
experimentalRegistry: true,
});
}
10 changes: 5 additions & 5 deletions packages/pages-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"devDependencies": {
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "^4.20241230.0",
"@miniflare/cache": "^2.14.2",
"@miniflare/core": "^2.14.2",
"@miniflare/html-rewriter": "^2.14.2",
"@miniflare/storage-memory": "^2.14.2",
"@miniflare/cache": "^2.14.4",
"@miniflare/core": "^2.14.4",
"@miniflare/html-rewriter": "^2.14.4",
"@miniflare/storage-memory": "^2.14.4",
"concurrently": "^8.2.2",
"glob": "^10.3.3"
"glob": "^10.4.5"
},
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/e2e/get-platform-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe("getPlatformProxy()", () => {
"index.mjs": dedent/*javascript*/ `
import { getPlatformProxy } from "${WRANGLER_IMPORT}"
const { env } = await getPlatformProxy({ experimentalRegistry: true });
const { env } = await getPlatformProxy();
const resp = ${code}
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/metafile.json

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@
"@sentry/node": "^7.86.0",
"@sentry/types": "^7.86.0",
"@sentry/utils": "^7.86.0",
"@types/body-parser": "^1.19.2",
"@types/command-exists": "^1.2.0",
"@types/express": "^4.17.13",
"@types/glob-to-regexp": "^0.4.1",
"@types/is-ci": "^3.0.0",
"@types/javascript-time-ago": "^2.0.3",
Expand All @@ -118,7 +116,6 @@
"@types/yargs": "^17.0.22",
"@vitest/ui": "catalog:default",
"@webcontainer/env": "^1.1.0",
"body-parser": "^1.20.0",
"chalk": "^5.2.0",
"cli-table3": "^0.6.3",
"cmd-shim": "^4.1.0",
Expand All @@ -127,11 +124,9 @@
"devtools-protocol": "^0.0.1182435",
"dotenv": "^16.0.0",
"execa": "^6.1.0",
"express": "^4.18.1",
"find-up": "^6.3.0",
"get-port": "^7.0.0",
"glob-to-regexp": "^0.4.1",
"http-terminator": "^3.2.0",
"https-proxy-agent": "7.0.2",
"ignore": "^5.2.0",
"is-ci": "^3.0.1",
Expand Down
5 changes: 4 additions & 1 deletion packages/wrangler/scripts/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { writeFileSync } from "node:fs";
import path from "node:path";
import * as esbuild from "esbuild";
import { EXTERNAL_DEPENDENCIES } from "./deps";
Expand Down Expand Up @@ -35,6 +36,7 @@ async function buildMain(flags: BuildFlags = {}) {
outdir,
platform: "node",
format: "cjs",
metafile: true,
external: EXTERNAL_DEPENDENCIES,
sourcemap: process.env.SOURCEMAPS !== "false",
inject: [path.join(__dirname, "../import_meta_url.js")],
Expand Down Expand Up @@ -64,7 +66,8 @@ async function buildMain(flags: BuildFlags = {}) {
const ctx = await esbuild.context(options);
await ctx.watch();
} else {
await esbuild.build(options);
const res = await esbuild.build(options);
writeFileSync("metafile.json", JSON.stringify(res.metafile));
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/__tests__/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,6 @@ describe.sequential("wrangler dev", () => {
--test-scheduled Test scheduled events by visiting /__scheduled in browser [boolean] [default: false]
--log-level Specify logging level [choices: \\"debug\\", \\"info\\", \\"log\\", \\"warn\\", \\"error\\", \\"none\\"] [default: \\"log\\"]
--show-interactive-dev-session Show interactive dev session (defaults to true if the terminal supports interactivity) [boolean]
--experimental-registry, --x-registry Use the experimental file based dev registry for multi-worker development [boolean] [default: true]
--experimental-vectorize-bind-to-prod Bind to production Vectorize indexes in local development mode [boolean] [default: false]",
"warn": "",
}
Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/__tests__/pages/pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe("pages", () => {
--persist-to Specify directory to use for local persistence (defaults to .wrangler/state) [string]
--log-level Specify logging level [choices: \\"debug\\", \\"info\\", \\"log\\", \\"warn\\", \\"error\\", \\"none\\"]
--show-interactive-dev-session Show interactive dev session (defaults to true if the terminal supports interactivity) [boolean]
--experimental-registry, --x-registry Use the experimental file based dev registry for multi-worker development [boolean] [default: true]
--experimental-vectorize-bind-to-prod Bind to production Vectorize indexes in local development mode [boolean] [default: false]"
`);
});
Expand Down
4 changes: 0 additions & 4 deletions packages/wrangler/src/api/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export async function unstable_dev(
showInteractiveDevSession,
testMode,
testScheduled,
fileBasedRegistry = true,
vectorizeBindToProd,
// 2. options for alpha/beta products/libs
d1Databases,
Expand Down Expand Up @@ -218,16 +217,13 @@ export async function unstable_dev(
logLevel: options?.logLevel ?? defaultLogLevel,
port: options?.port ?? 0,
experimentalProvision: undefined,
experimentalDevEnv: undefined,
experimentalRegistry: fileBasedRegistry,
experimentalVectorizeBindToProd: vectorizeBindToProd ?? false,
enableIpc: options?.experimental?.enableIpc,
};

//outside of test mode, rebuilds work fine, but only one instance of wrangler will work at a time
const devServer = await run(
{
FILE_BASED_REGISTRY: fileBasedRegistry,
// TODO: can we make this work?
MULTIWORKER: false,
RESOURCES_PROVISION: false,
Expand Down
7 changes: 0 additions & 7 deletions packages/wrangler/src/api/integrations/platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ export type GetPlatformProxyOptions = {
* If `false` is specified no data is persisted on the filesystem.
*/
persist?: boolean | { path: string };
/**
* Use the experimental file-based dev registry for service discovery
*
* Note: this feature is experimental
*/
experimentalRegistry?: boolean;
};

/**
Expand Down Expand Up @@ -110,7 +104,6 @@ export async function getPlatformProxy<

const miniflareOptions = await run(
{
FILE_BASED_REGISTRY: Boolean(options.experimentalRegistry ?? true),
MULTIWORKER: false,
RESOURCES_PROVISION: false,
},
Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export * from "./api/integrations";

// Export internal APIs required by the Vitest integration as `unstable_`
export { default as unstable_splitSqlQuery } from "./d1/splitter";
export { startWorkerRegistryServer as unstable_startWorkerRegistryServer } from "./dev-registry";

// `miniflare-cli/assets` dynamically imports`@cloudflare/pages-shared/environment-polyfills`.
// `@cloudflare/pages-shared/environment-polyfills/types.ts` defines `global`
Expand Down
1 change: 0 additions & 1 deletion packages/wrangler/src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ export type DeployArgs = StrictYargsOptionsToInterface<typeof deployOptions>;
export async function deployHandler(args: DeployArgs) {
await run(
{
FILE_BASED_REGISTRY: false,
RESOURCES_PROVISION: args.experimentalProvision ?? false,
MULTIWORKER: false,
},
Expand Down
40 changes: 5 additions & 35 deletions packages/wrangler/src/dev-registry/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { getFlag } from "../experimental-flags";
import { FileRegistry } from "./file-registry";
import { ServerRegistry } from "./server-registry";
import type { Binding } from "../api";
import type { Config } from "../config";
import type {
Expand All @@ -11,16 +9,6 @@ import type {

export type { WorkerDefinition, WorkerRegistry, WorkerEntrypointsDefinition };

// Safety of `!`: `parseInt(undefined)` is NaN
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
let DEV_REGISTRY_PORT = parseInt(process.env.WRANGLER_WORKER_REGISTRY_PORT!);
if (Number.isNaN(DEV_REGISTRY_PORT)) {
DEV_REGISTRY_PORT = 6284;
}

export const startWorkerRegistryServer =
ServerRegistry.startWorkerRegistryServer;

/**
* Start the service registry. It's a simple server
* that exposes endpoints for registering and unregistering
Expand All @@ -29,21 +17,14 @@ export const startWorkerRegistryServer =
export async function startWorkerRegistry(
listener?: (registry: WorkerRegistry | undefined) => void
) {
if (getFlag("FILE_BASED_REGISTRY")) {
return FileRegistry.startWorkerRegistry(listener);
}

return ServerRegistry.startWorkerRegistry();
return FileRegistry.startWorkerRegistry(listener);
}

/**
* Stop the service registry.
*/
export async function stopWorkerRegistry() {
if (getFlag("FILE_BASED_REGISTRY")) {
return FileRegistry.stopWorkerRegistry();
}
return ServerRegistry.stopWorkerRegistry();
return FileRegistry.stopWorkerRegistry();
}

/**
Expand All @@ -53,10 +34,7 @@ export async function registerWorker(
name: string,
definition: WorkerDefinition
) {
if (getFlag("FILE_BASED_REGISTRY")) {
return FileRegistry.registerWorker(name, definition);
}
return ServerRegistry.registerWorker(name, definition);
return FileRegistry.registerWorker(name, definition);
}

/**
Expand All @@ -65,11 +43,7 @@ export async function registerWorker(
export async function getRegisteredWorkers(): Promise<
WorkerRegistry | undefined
> {
if (getFlag("FILE_BASED_REGISTRY")) {
return FileRegistry.getRegisteredWorkers();
}

return ServerRegistry.getRegisteredWorkers();
return FileRegistry.getRegisteredWorkers();
}

/**
Expand Down Expand Up @@ -120,9 +94,5 @@ export async function getBoundRegisteredWorkers(
export async function devRegistry(
cb: (workers: WorkerRegistry | undefined) => void
): Promise<(name?: string) => Promise<void>> {
if (getFlag("FILE_BASED_REGISTRY")) {
return FileRegistry.devRegistry(cb);
}

return ServerRegistry.devRegistry(cb);
return FileRegistry.devRegistry(cb);
}
Loading

0 comments on commit 79bf518

Please sign in to comment.