Skip to content

Commit 34f9797

Browse files
Provides support for run_worker_first option (#7897)
- Warning for sunsetting of experimental_serve_directly - Error for using run_worker_first and experimental_serve_directly together - Sends run_worker_first field to EWC (in production) instead of old `serve_directly`
1 parent 5251052 commit 34f9797

File tree

26 files changed

+364
-87
lines changed

26 files changed

+364
-87
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@cloudflare/workers-shared": minor
3+
"wrangler": minor
4+
---
5+
6+
chore: provides `run_worker_first` for Worker-script-first configuration. Deprecates `experimental_serve_directly`.

fixtures/asset-config/html-handling.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ describe.each(testSuites)("$title", ({ title, suite }) => {
6464
return {
6565
html_handling,
6666
not_found_handling: "none",
67-
serve_directly: true,
67+
run_worker_first: true,
68+
serve_directly: false,
6869
};
6970
});
7071
});

fixtures/asset-config/redirects.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ describe("[Asset Worker] `test location rewrite`", () => {
4141
return {
4242
html_handling: "none",
4343
not_found_handling: "none",
44-
serve_directly: true,
44+
run_worker_first: true,
45+
serve_directly: false,
4546
};
4647
});
4748
});

fixtures/asset-config/url-normalization.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ describe("[Asset Worker] `test slash normalization`", () => {
4141
return {
4242
html_handling: "none",
4343
not_found_handling: "none",
44-
serve_directly: true,
44+
run_worker_first: true,
45+
serve_directly: false,
4546
};
4647
});
4748
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# workers-assets-with-user-worker"
2+
3+
`workers-assets-with-user-worker-run-worker-first"` is a test fixture that showcases Workers with Assets using the run_worker_first option. This particular fixture forces a user Worker to be invoked, even if it otherwise would have matched an assets request.
4+
5+
## dev
6+
7+
To start a dev session you can run
8+
9+
```
10+
wrangler dev
11+
```
12+
13+
## Run tests
14+
15+
```
16+
npm run test
17+
```

fixtures/workers-with-assets-serve-directly/package.json renamed to fixtures/workers-with-assets-run-worker-first/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "workers-assets-with-user-worker-serve-directly",
2+
"name": "workers-assets-with-user-worker-run-worker-first",
33
"private": true,
44
"scripts": {
55
"check:type": "tsc",

fixtures/workers-with-assets-serve-directly/tests/index.test.ts renamed to fixtures/workers-with-assets-run-worker-first/tests/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { fetch } from "undici";
33
import { afterAll, beforeAll, describe, it } from "vitest";
44
import { runWranglerDev } from "../../shared/src/run-wrangler-long-lived";
55

6-
describe("[Workers + Assets] serve_directly false", () => {
6+
describe("[Workers + Assets] run_worker_first true", () => {
77
let ip: string, port: number, stop: (() => Promise<unknown>) | undefined;
88

99
beforeAll(async () => {

0 commit comments

Comments
 (0)