Repository navigation
[vite-plugin v1 backport] Update November 23 runtime and Vite logging #17130
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
Merged
petebacondarwin
merged 3 commits into
codex/vite-v1-backport-17091
from
codex/vite-v1-backport-17070
Nov 25, 2026
+440
−228
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
aef57d8
[vite-plugin v1 backport] Prepare November 23 runtime upgrade
petebacondarwin aedaa07
[vite-plugin v1 backport] Consume published runtime and log-path fixes
petebacondarwin 8ace7ad
[vite-plugin v1 backport] Normalize logging test subprocess directory
petebacondarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 @@ | ||
| --- | ||
| "@cloudflare/vite-plugin": patch | ||
| --- | ||
|
|
||
| Respect `WRANGLER_LOG_PATH` set after importing the plugin in `vite.config.ts` | ||
|
|
||
| Require Wrangler 4.168.0 or newer, which resolves the debug log path on first use. A path set in the Vite configuration body now selects the configured log file. |
This file contains hidden or 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,7 @@ | ||
| --- | ||
| "@cloudflare/vite-plugin": patch | ||
| --- | ||
|
|
||
| Update the local runtime and default compatibility date to November 23 | ||
|
|
||
| Use Miniflare 5.20261123.1-beta, workerd 1.20261123.1 and the matching Workers types. The default compatibility date advances to November 23. Local Stream bindings support caption retrieval and video customer codes; R2 pagination uses UTF-8 key order, and KV bulk reads preserve metadata for stored JSON nulls. | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
71 changes: 71 additions & 0 deletions
71
packages/vite-plugin-cloudflare/src/__tests__/log-path.spec.ts
This file contains hidden or 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,71 @@ | ||
| import { execFile } from "node:child_process"; | ||
| import * as fs from "node:fs/promises"; | ||
| import { promisify } from "node:util"; | ||
| import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers"; | ||
| import { afterEach, test, vi } from "vitest"; | ||
|
|
||
| const execFileAsync = promisify(execFile); | ||
| const pluginUrl = new URL("../../dist/index.mjs", import.meta.url).href; | ||
| const viteUrl = import.meta.resolve("vite"); | ||
|
|
||
| runInTempDir(); | ||
| afterEach(() => vi.unstubAllEnvs()); | ||
|
|
||
| test("respects WRANGLER_LOG_PATH set in the Vite config after importing the plugin", async ({ | ||
| expect, | ||
| }) => { | ||
| await seed({ | ||
| "wrangler.json": JSON.stringify({ | ||
| name: "log-path", | ||
| main: "./index.js", | ||
| compatibility_date: "2026-04-01", | ||
| }), | ||
| "index.js": 'export default { fetch: () => new Response("ok") };', | ||
| "vite.config.mjs": ` | ||
| import { cloudflare } from ${JSON.stringify(pluginUrl)}; | ||
| process.env.WRANGLER_LOG_PATH = "configured-logs/vite.log"; | ||
| export default { | ||
| plugins: [cloudflare({ inspectorPort: false, persistState: false, remoteBindings: false })], | ||
| server: { watch: null } | ||
| }; | ||
| `, | ||
| }); | ||
| // A fresh process preserves the original import-before-configuration order, | ||
| // without a debug-log path cached by another plugin test. | ||
| // Expand Windows 8.3 directory names so Vite resolves the Worker entry. | ||
| const root = await fs.realpath(process.cwd()); | ||
| await execFileAsync( | ||
| process.execPath, | ||
| [ | ||
| "--input-type=module", | ||
| "--eval", | ||
| ` | ||
| import assert from "node:assert"; | ||
| import { createServer } from ${JSON.stringify(viteUrl)}; | ||
| const server = await createServer(); | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
|
||
| try { | ||
| await server.listen(0); | ||
| const url = server.resolvedUrls?.local[0]; | ||
| assert(url); | ||
| assert.equal(await (await fetch(url)).text(), "ok"); | ||
| } finally { | ||
| await server.close(); | ||
| } | ||
| `, | ||
| ], | ||
| { | ||
| cwd: root, | ||
| env: { | ||
| ...process.env, | ||
| PWD: root, | ||
| WRANGLER_LOG_PATH: "", | ||
| WRANGLER_WRITE_LOGS: "true", | ||
| WRANGLER_SEND_METRICS: "false", | ||
| }, | ||
| timeout: 30_000, | ||
| } | ||
| ); | ||
| expect(await fs.readFile("configured-logs/vite.log", "utf8")).toContain( | ||
| "---" | ||
| ); | ||
| }); | ||
This file contains hidden or 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
107 changes: 107 additions & 0 deletions
107
packages/vite-plugin-cloudflare/src/__tests__/runtime-bindings.spec.ts
This file contains hidden or 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,107 @@ | ||
| import assert from "node:assert"; | ||
| import * as fs from "node:fs/promises"; | ||
| import { cloudflare } from "@cloudflare/vite-plugin"; | ||
| import { runInTempDir, seed } from "@cloudflare/workers-utils/test-helpers"; | ||
| import { createServer } from "vite"; | ||
| import { afterEach, beforeEach, describe, test, vi } from "vitest"; | ||
|
|
||
| describe("local runtime bindings through Vite", () => { | ||
| runInTempDir(); | ||
| afterEach(() => vi.unstubAllEnvs()); | ||
| beforeEach(async () => { | ||
| if (process.platform === "win32") { | ||
| const root = await fs.realpath(process.cwd()); | ||
| process.chdir(root); | ||
| vi.stubEnv("PWD", root); | ||
| } | ||
| await seed({ | ||
| "wrangler.json": JSON.stringify({ | ||
| name: "runtime-bindings", | ||
| main: "./index.js", | ||
| compatibility_date: "2026-04-01", | ||
| stream: { binding: "STREAM" }, | ||
| r2_buckets: [{ binding: "BUCKET", bucket_name: "runtime-bucket" }], | ||
| kv_namespaces: [{ binding: "KV", id: "runtime-kv" }], | ||
| }), | ||
| "index.js": ` | ||
| export default { | ||
| async fetch(request, env) { | ||
| switch (new URL(request.url).pathname) { | ||
| case "/stream": { | ||
| const video = await env.STREAM.upload(new Response(new Uint8Array([0, 1, 2, 3])).body); | ||
| const captions = env.STREAM.video(video.id).captions; | ||
| await captions.upload("en", new Response("test").body); | ||
| await captions.generate("fr"); | ||
| const uploaded = await new Response(await captions.get("en")).text(); | ||
| const generated = await new Response(await captions.get("fr")).text(); | ||
| let missing; | ||
| try { await captions.get("de"); } catch (error) { missing = error.message; } | ||
| return Response.json({ customerCode: video.customerCode, uploaded, generated, missing }); | ||
| } | ||
| case "/r2": { | ||
| for (const key of ["A", "📷", "📸"]) await env.BUCKET.put(key, "value"); | ||
| const first = await env.BUCKET.list({ startAfter: "A", limit: 1 }); | ||
| const second = await env.BUCKET.list({ startAfter: "A", limit: 1, cursor: first.cursor }); | ||
| return Response.json([first, second].map(page => page.objects.map(object => object.key))); | ||
| } | ||
| case "/kv": { | ||
| await env.KV.put("null", "null", { metadata: { testing: "null" } }); | ||
| const values = await env.KV.getWithMetadata(["null", "missing"], "json"); | ||
| return Response.json(Object.fromEntries(values)); | ||
| } | ||
| } | ||
| return new Response("not found", { status: 404 }); | ||
| } | ||
| }; | ||
| `, | ||
| }); | ||
| }); | ||
|
|
||
| test.for([ | ||
| { | ||
| path: "/stream", | ||
| result: { | ||
| customerCode: "placeholder", | ||
| uploaded: "test", | ||
| generated: "WEBVTT\n", | ||
| missing: "Caption not found", | ||
| }, | ||
| }, | ||
| { path: "/r2", result: [["📷"], ["📸"]] }, | ||
| { | ||
| path: "/kv", | ||
| result: { | ||
| null: { value: null, metadata: { testing: "null" } }, | ||
| missing: null, | ||
| }, | ||
| }, | ||
| ])( | ||
| "serves $path with the released runtime behavior", | ||
| async ({ path, result }, { expect, onTestFinished }) => { | ||
| const server = await createServer({ | ||
| root: process.cwd(), | ||
| configFile: false, | ||
| logLevel: "silent", | ||
| server: { watch: null }, | ||
| plugins: [ | ||
| cloudflare({ | ||
| inspectorPort: false, | ||
| persistState: false, | ||
| remoteBindings: false, | ||
| }), | ||
| ], | ||
| }); | ||
| onTestFinished(() => server.close()); | ||
| await server.listen(0); | ||
| const url = server.resolvedUrls?.local[0]; | ||
| assert(url); | ||
| const response = await fetch(new URL(path, url)); | ||
| expect(response.status).toBe(200); | ||
| expect(await response.json()).toEqual( | ||
| path === "/stream" | ||
| ? { ...result, missing: expect.stringContaining("Caption not found") } | ||
| : result | ||
| ); | ||
| } | ||
| ); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.