-
Notifications
You must be signed in to change notification settings - Fork 702
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Squashed commit of the following: commit 7d0f2d6 Author: Somhairle MacLeòid <smacleod@cloudflare.com> Date: Thu May 30 13:35:53 2024 +0100 Update index.ts commit 4fac979 Author: Somhairle MacLeòid <smacleod@cloudflare.com> Date: Thu May 30 13:10:39 2024 +0100 Create flat-days-punch.md commit 2c7bc56 Author: Samuel Macleod <smacleod@cloudflare.com> Date: Thu May 30 12:52:32 2024 +0100 Remove cirular dependency between logger and env var factory which Vitest/Vite can't understand commit e4f2efb Author: Samuel Macleod <smacleod@cloudflare.com> Date: Thu May 30 02:48:47 2024 +0100 lint commit c678631 Author: Samuel Macleod <smacleod@cloudflare.com> Date: Thu May 30 02:35:29 2024 +0100 restore logging & enable tests commit 4a87a51 Author: Samuel Macleod <smacleod@cloudflare.com> Date: Thu May 30 01:53:33 2024 +0100 bindings passthrough + persistence path commit f1ff546 Author: Samuel Macleod <smacleod@cloudflare.com> Date: Thu May 30 01:25:26 2024 +0100 handle empty routes array in getInferredHost commit cc1c2f0 Author: Samuel Macleod <smacleod@cloudflare.com> Date: Thu May 30 01:20:08 2024 +0100 ignore https options in LocalRuntimeController (handled in Proxy commit 87b5a98 Author: Samuel Macleod <smacleod@cloudflare.com> Date: Thu May 30 00:56:21 2024 +0100 starting to get tests passing commit 6b6204d Author: Samuel Macleod <smacleod@cloudflare.com> Date: Wed May 29 23:06:26 2024 +0100 Separate preview sessions and tokens commit 6912a49 Author: Samuel Macleod <smacleod@cloudflare.com> Date: Wed May 29 21:33:17 2024 +0100 fix build + lint + types commit c9d70b6 Merge: db6eada 8033afb Author: Samuel Macleod <smacleod@cloudflare.com> Date: Wed May 29 21:14:51 2024 +0100 Merge branch 'startDevWorker-milestone-2-local' into remote-runtime-controller commit db6eada Merge: 10a9495 90d6be7 Author: Somhairle MacLeòid <smacleod@cloudflare.com> Date: Wed May 29 21:09:43 2024 +0100 Merge branch 'startDevWorker-milestone-2-local' into remote-runtime-controller commit 10a9495 Merge: 0842071 be715bd Author: Samuel Macleod <smacleod@cloudflare.com> Date: Wed May 29 20:57:04 2024 +0100 Merge branch 'startDevWorker-milestone-2-local' into remote-runtime-controller commit 0842071 Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Tue May 21 16:16:48 2024 +0100 chore: pull in changes from LocalRuntimeController PR commit a2a6ba1 Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Tue May 21 15:15:12 2024 +0100 update startDevWorker types from LocalRuntimeController PR commit 6e38a28 Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Sun May 19 21:25:28 2024 +0100 fix: make unstable_dev respect experimentalDevenvRuntime commit 82ce0a1 Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Sun May 19 21:50:37 2024 +0100 fix: unstable_dev with node v18 by defaulting .ip to 127.0.0.1 + enable unstable_dev (previously: wrangler-dev-api-app) fixture tests to run in ci commit 341d212 Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Sun May 19 20:32:48 2024 +0100 implement --experimental-devenv-runtime for conditional use of DevEnv-{Local|Remote}RuntimeController commit db353b2 Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Sun May 19 20:08:12 2024 +0100 chore: refactor bundle ref back to normal variable commit dd55a24 Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Sun May 19 19:58:57 2024 +0100 fix: auth + accountId selection from React flow with RemoteRuntimeController commit c0c88f2 Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Sun May 19 19:39:26 2024 +0100 use an actual onBundleComplete callback instead of relying on useEffect + deps tracking commit 2f8b98c Author: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com> Date: Fri May 17 16:57:20 2024 +0100 wip: RemoteRuntimeController + integration * Refactor errors to use shared definition * Rename flag * Remove extraneous console logs * Fix spacing * Actually teardown * Address comments * Fix flags * Remove ip overriding * Hardcode IP in unstable_dev * Cleanup unstable options * Error on invalid text_blobs * Teardown on change from remote -> local and vice-versa * add volta * e2e test for switching runtime race conditions * Update snapshots * immutable config * more testing * file url
- Loading branch information
Showing
27 changed files
with
1,062 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
feat: Adds the experimental flag `--x-dev-env` which opts in to using an experimental code path for `wrangler dev` and `wrangler dev --remote`. There should be no observable behaviour changes when this flag is enabled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`basic js dev: 'wrangler dev --remote --x-dev-env' > can modify worker during wrangler dev --remote --x-dev-env 1`] = `"Hello World!"`; | ||
|
||
exports[`basic js dev: 'wrangler dev --remote --x-dev-env' > can modify worker during wrangler dev --remote --x-dev-env 2`] = `"Updated Worker! value"`; | ||
|
||
exports[`basic js dev: 'wrangler dev --remote' > can modify worker during wrangler dev --remote 1`] = `"Hello World!"`; | ||
|
||
exports[`basic js dev: 'wrangler dev --remote' > can modify worker during wrangler dev --remote 2`] = `"Updated Worker! value"`; | ||
|
||
exports[`basic js dev: 'wrangler dev --x-dev-env' > can modify worker during wrangler dev --x-dev-env 1`] = `"Hello World!"`; | ||
|
||
exports[`basic js dev: 'wrangler dev --x-dev-env' > can modify worker during wrangler dev --x-dev-env 2`] = `"Updated Worker! value"`; | ||
|
||
exports[`basic js dev: 'wrangler dev' > can modify worker during wrangler dev 1`] = `"Hello World!"`; | ||
|
||
exports[`basic js dev: 'wrangler dev' > can modify worker during wrangler dev 2`] = `"Updated Worker! value"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import shellac from "shellac"; | ||
import dedent from "ts-dedent"; | ||
import { beforeEach, describe, expect, it } from "vitest"; | ||
import { CLOUDFLARE_ACCOUNT_ID } from "./helpers/account-id"; | ||
import { makeRoot, seed } from "./helpers/setup"; | ||
import { WRANGLER_IMPORT } from "./helpers/wrangler"; | ||
|
||
// TODO(DEVX-1262): re-enable when we have set an API token with the proper AI permissions | ||
describe("switching runtimes", () => { | ||
let run: typeof shellac; | ||
beforeEach(async () => { | ||
const root = await makeRoot(); | ||
|
||
run = shellac.in(root).env(process.env); | ||
await seed(root, { | ||
"wrangler.toml": dedent` | ||
name = "dev-env-app" | ||
account_id = "${CLOUDFLARE_ACCOUNT_ID}" | ||
compatibility_date = "2023-01-01" | ||
`, | ||
"index.mjs": dedent/*javascript*/ ` | ||
const firstRemote = process.argv[2] === "remote" | ||
import { unstable_DevEnv as DevEnv } from "${WRANGLER_IMPORT}"; | ||
const devEnv = new DevEnv() | ||
let config = { | ||
name: "worker", | ||
script: "", | ||
compatibilityFlags: ["nodejs_compat"], | ||
compatibilityDate: "2023-10-01", | ||
dev: { | ||
remote: firstRemote, | ||
auth: { | ||
accountId: process.env.CLOUDFLARE_ACCOUNT_ID, | ||
apiToken: process.env.CLOUDFLARE_API_TOKEN | ||
} | ||
} | ||
}; | ||
let bundle = { | ||
type: "esm", | ||
modules: [], | ||
id: 0, | ||
path: "/virtual/esm/index.mjs", | ||
entrypointSource: "export default { fetch() { return new Response('Hello World " + (firstRemote ? 'local' : 'remote') + " runtime') } }", | ||
entry: { | ||
file: "esm/index.mjs", | ||
directory: "/virtual/", | ||
format: "modules", | ||
moduleRoot: "/virtual", | ||
name: undefined, | ||
}, | ||
dependencies: {}, | ||
sourceMapPath: undefined, | ||
sourceMapMetadata: undefined, | ||
}; | ||
devEnv.proxy.onConfigUpdate({ | ||
type: "configUpdate", | ||
config, | ||
}); | ||
devEnv.runtimes.forEach((runtime) => | ||
runtime.onBundleStart({ | ||
type: "bundleStart", | ||
config, | ||
}) | ||
); | ||
devEnv.runtimes.forEach((runtime) => | ||
runtime.onBundleComplete({ | ||
type: "bundleComplete", | ||
config, | ||
bundle, | ||
}) | ||
); | ||
// Immediately switch runtime | ||
config = { ...config, dev: { ...config.dev, remote: !firstRemote } }; | ||
bundle = {...bundle, entrypointSource: "export default { fetch() { return new Response('Hello World " + (firstRemote ? 'local' : 'remote') + " runtime') } }"} | ||
devEnv.proxy.onConfigUpdate({ | ||
type: "configUpdate", | ||
config, | ||
}); | ||
devEnv.runtimes.forEach((runtime) => | ||
runtime.onBundleStart({ | ||
type: "bundleStart", | ||
config, | ||
}) | ||
); | ||
devEnv.runtimes.forEach((runtime) => | ||
runtime.onBundleComplete({ | ||
type: "bundleComplete", | ||
config, | ||
bundle, | ||
}) | ||
); | ||
const { proxyWorker } = await devEnv.proxy.ready.promise; | ||
await devEnv.proxy.runtimeMessageMutex.drained(); | ||
console.log(await proxyWorker.dispatchFetch("http://example.com").then(r => r.text())) | ||
process.exit(0); | ||
`, | ||
"package.json": dedent` | ||
{ | ||
"name": "ai-app", | ||
"version": "0.0.0", | ||
"private": true | ||
} | ||
`, | ||
}); | ||
}); | ||
it("can switch from local to remote, with first fetch returning remote", async () => { | ||
const { stdout } = await run`$ node index.mjs local`; | ||
expect(stdout).toContain("Hello World remote runtime"); | ||
}); | ||
it("can switch from remote to local, with first fetch returning local", async () => { | ||
const { stdout } = await run`$ node index.mjs remote`; | ||
expect(stdout).toContain("Hello World local runtime"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.