Skip to content

Commit

Permalink
Revert "Modify router-worker logic to allow for running user-worker a…
Browse files Browse the repository at this point in the history
…head of assets (#7303)"

This reverts commit 0d314ed.
  • Loading branch information
emily-shen committed Nov 26, 2024
1 parent 95522fc commit 3de72fd
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 242 deletions.
5 changes: 0 additions & 5 deletions .changeset/funny-dingos-guess.md

This file was deleted.

1 change: 0 additions & 1 deletion packages/workers-shared/asset-worker/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ account_id = "0f1b8aa119a907021f659042f95ea9ba"
workers_dev = false
main = "src/index.ts"
compatibility_date = "2024-07-31"
# nodejs_compat required when using @cloudflare/vitest-pool-workers
compatibility_flags = ["nodejs_compat"]

[[unsafe.bindings]]
Expand Down
9 changes: 3 additions & 6 deletions packages/workers-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@
"bundle:router-worker:prod": "pnpm run bundle:router-worker --minify",
"check:lint": "eslint . --max-warnings=0",
"check:type": "pnpm run check:type:tests && tsc",
"check:type:tests": "tsc -p ./asset-worker/tests/tsconfig.json && tsc -p ./router-worker/tests/tsconfig.json",
"check:type:tests": "tsc -p ./asset-worker/tests/tsconfig.json",
"clean": "rimraf dist",
"deploy": "pnpm run deploy:router-worker && pnpm run deploy:asset-worker",
"deploy:asset-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler versions upload --experimental-versions -c asset-worker/wrangler.toml",
"deploy:router-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler versions upload --experimental-versions -c router-worker/wrangler.toml",
"dev": "pnpm run clean && concurrently -n bundle:asset-worker,bundle:router-worker -c blue,magenta \"pnpm run bundle:asset-worker --watch\" \"pnpm run bundle:router-worker --watch\"",
"test": "concurrently --group -n router-worker,asset-worker \"pnpm run test:router-worker\" \"pnpm run test:asset-worker\"",
"test:asset-worker": "vitest -c asset-worker/vitest.config.mts --dir asset-worker",
"test:ci": "pnpm run test",
"test:router-worker": "vitest -c router-worker/vitest.config.mts --dir router-worker",
"test": "vitest",
"test:ci": "vitest run",
"types:emit": "tsc index.ts --declaration --emitDeclarationOnly --declarationDir ./dist"
},
"dependencies": {
Expand All @@ -48,7 +46,6 @@
},
"devDependencies": {
"@cloudflare/eslint-config-worker": "workspace:*",
"@cloudflare/vitest-pool-workers": "latest",
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "^4.20241106.0",
"@types/mime": "^3.0.4",
Expand Down
13 changes: 0 additions & 13 deletions packages/workers-shared/router-worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@ export default {
}

const maybeSecondRequest = request.clone();

// User's configuration indicates they want user-Worker to run ahead of any
// assets. Do not provide any fallback logic.
if (env.CONFIG.invoke_user_worker_ahead_of_assets) {
if (!env.CONFIG.has_user_worker) {
throw new Error(
"Fetch for user worker without having a user worker binding"
);
}
return env.USER_WORKER.fetch(maybeSecondRequest);
}

// Otherwise, we try to first fetch assets, falling back to user-Worker.
if (env.CONFIG.has_user_worker) {
if (await env.ASSET_WORKER.unstable_canFetch(request)) {
analytics.setData({ dispatchtype: DISPATCH_TYPE.ASSETS });
Expand Down
74 changes: 0 additions & 74 deletions packages/workers-shared/router-worker/tests/index.test.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/workers-shared/router-worker/tests/tsconfig.json

This file was deleted.

13 changes: 0 additions & 13 deletions packages/workers-shared/router-worker/vitest.config.mts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/workers-shared/router-worker/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ account_id = "0f1b8aa119a907021f659042f95ea9ba"
workers_dev = false
main = "src/index.ts"
compatibility_date = "2024-07-31"
# nodejs_compat required when using @cloudflare/vitest-pool-workers
compatibility_flags = ["nodejs_compat", "no_nodejs_compat_v2"]

[version_metadata]
binding = "VERSION_METADATA"
Expand Down
2 changes: 1 addition & 1 deletion packages/workers-shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"sourceMap": true,
"forceConsistentCasingInFileNames": true,
"useUnknownInCatchVariables": false,
"types": ["@cloudflare/workers-types/experimental", "@types/node"]
"types": ["@cloudflare/workers-types/experimental"]
},
"include": ["**/*.ts", "vitest.config.mts"],
"exclude": ["node_modules", "dist", "**/tests", "**/*.test.ts"]
Expand Down
1 change: 0 additions & 1 deletion packages/workers-shared/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { z } from "zod";

export const RoutingConfigSchema = z.object({
has_user_worker: z.boolean().optional(),
invoke_user_worker_ahead_of_assets: z.boolean().optional(),
});

export const AssetConfigSchema = z.object({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineProject, mergeConfig } from "vitest/config";
import configShared from "../../../vitest.shared.js";
import configShared from "../../vitest.shared";

export default mergeConfig(
configShared,
defineProject({
test: {
include: ["tests/**.{test,spec}.{ts,js}"],
include: ["asset-worker/tests/**.{test,spec}.{ts,js}"],
globals: true,
},
})
Expand Down
109 changes: 0 additions & 109 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3de72fd

Please sign in to comment.