Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/vite-plugin-playgrounds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ jobs:
}
console.log(`VITE_PLUGIN_BUILD_HASH=${task.hash}`);
' >> "$GITHUB_ENV"
# The exact Vite 8 workspace patch is intentionally unused by this
# compatibility job after downgrading to Vite 7.
- name: Downgrade to Vite 7
if: steps.changes.outputs.everything_but_markdown == 'true' && matrix.vite == 'vite-7'
run: |
pnpm --config.allow-unused-patches=true update -r --no-save vite@^7.0.0
pnpm update -r --no-save vite@^7.0.0
- name: Run dev playground tests
if: steps.changes.outputs.everything_but_markdown == 'true'
# We use `--only` to prevent TurboRepo from rebuilding dependencies
Expand Down
4 changes: 4 additions & 0 deletions packages/miniflare/test/plugins/cache/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ test("default and named caches are disjoint", async ({ expect }) => {
});

test("purgeCache clears all default cache entries", async ({ expect }) => {
// Purging does not need a fake clock. An idle object can be evicted on slow
// runners, losing its fake clock and expiring entries written in 1970.
await ctx.defaultObject.disableFakeTimers();
const cache = ctx.caches.default;
const headers = { "Cache-Control": "max-age=3600" };

Expand Down Expand Up @@ -558,6 +561,7 @@ test("purgeCache clears all default cache entries", async ({ expect }) => {
});

test("purgeCache clears specific named cache", async ({ expect }) => {
await ctx.defaultObject.disableFakeTimers();
const defaultCache = ctx.caches.default;
const namedCache = await ctx.caches.open("my-cache");
const headers = { "Cache-Control": "max-age=3600" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import {
getTextResponse,
isBuild,
mockFileChange,
viteServer,
viteTestUrl,
WAIT_FOR_OPTIONS,
} from "../../__test-utils__";

test.runIf(!isBuild)(
"serves requests and watches config after workerd crashes",
async ({ expect }) => {
if (!("restart" in viteServer)) {
throw new Error("Expected a Vite dev server");
}

await vi.waitFor(
async () =>
expect(await getTextResponse()).toContain(
Expand All @@ -21,6 +26,7 @@ test.runIf(!isBuild)(
const initialRuntimeResponse = await fetch(`${viteTestUrl}/__runtime-id`);
expect(initialRuntimeResponse.ok).toBe(true);
const initialRuntimeId = await initialRuntimeResponse.text();
const restart = vi.spyOn(viteServer, "restart");

// This request is not expected to complete, since it crashes the runtime
// that is serving it, so keep the abort short to avoid stalling the test.
Expand All @@ -29,9 +35,16 @@ test.runIf(!isBuild)(
}).catch(() => undefined);
expect(crashResponse?.ok).not.toBe(true);

// These requests race a workerd restart, which is slow on Windows CI. The
// aborts must be long enough for a cold runtime to answer, otherwise every
// `waitFor` attempt aborts and the retries can never succeed.
// Requests can succeed before Vite finishes swapping servers and attaching
// config watchers. Wait for the crash recovery itself before editing config.
await vi.waitFor(
() => expect(restart).toHaveBeenCalled(),
WAIT_FOR_OPTIONS
);
await restart.mock.results[0]?.value;

// Keep probes bounded, but leave enough time for a cold runtime to answer
// on slow Windows CI runners.
await vi.waitFor(async () => {
const runtimeId = await fetch(`${viteTestUrl}/__runtime-id`, {
signal: AbortSignal.timeout(10_000),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ import assert from "node:assert";
import * as fs from "node:fs";
import * as path from "node:path";
import { test } from "vitest";
import {
getJsonResponse,
isBuild,
page,
rootDir,
satisfiesMinimumViteVersion,
} from "../../__test-utils__";
import { getJsonResponse, isBuild, page, rootDir } from "../../__test-utils__";

function getWorkerOutput() {
const workerDir = path.join(rootDir, ".cloudflare/output/v0/workers/default");
Expand Down Expand Up @@ -42,12 +36,7 @@ test.runIf(isBuild)(
}
);

// The Worker-scoped esbuild override on Vite 6 and 7 must not reach the client.
// Vite 8 has no such override, since the client keeps its own target. Also, the
// pinned Vite 8.1.5 (Rolldown 1.1.5) leaves `using` in client bundles at an
// explicit target with or without this plugin, so the assertion only holds on
// Vite 6 and 7.
test.runIf(isBuild && !satisfiesMinimumViteVersion("8.0.0"))(
test.runIf(isBuild)(
"lowers using declarations in the client build",
async ({ expect }) => {
const clientDir = path.join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,30 @@ describe("BundleController", { retry: 5, timeout: 10_000 }, () => {
// has finished its initial scan, so repeat the edit until a rebuild
// observes it. Poll recorded events rather than registering a waiter
// per attempt, because timed-out waiters would consume later events.
// Check before editing so a successful poll doesn't start another
// rebuild that can outlive teardown and access the removed directory.
let attempt = 0;
await vi.waitFor(
await vi.waitUntil(
async () => {
const renamed = bus.events.some(
(event) =>
event.type === "bundleComplete" &&
event.bundle.entry.exports.includes("Admin")
);
if (renamed) {
return true;
}
await seed({
"src/index.ts": `export class Admin {} // ${attempt++}`,
});
const bundles = bus.events.filter(
(event) => event.type === "bundleComplete"
);
expect(bundles.at(-1)?.bundle.entry.exports).toEqual(["Admin"]);
return false;
},
{ timeout: 8_000, interval: 500 }
);
const bundles = bus.events.filter(
(event) => event.type === "bundleComplete"
);
expect(bundles.at(-1)?.bundle.entry.exports).toEqual(["Admin"]);
}
);

Expand Down
5 changes: 3 additions & 2 deletions packages/wrangler/src/__tests__/helpers/fake-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ export class FakeBus implements ControllerBus {
* Wait for a specific event type to be dispatched.
* @param type - The event type to wait for
* @param predicate - Optional predicate to filter events
* @param timeoutMs - Timeout in milliseconds (default: 15000)
* @param timeoutMs - Timeout in milliseconds (default: 30000 on Windows,
* 15000 elsewhere, to allow for slower runtime startup on Windows CI)
* @returns Promise that resolves with the matching event
*/
waitFor<T extends EventType>(
type: T,
predicate?: (e: EventFor<T>) => boolean,
timeoutMs = 15000
timeoutMs = process.platform === "win32" ? 30_000 : 15_000
): Promise<EventFor<T>> {
return new Promise((resolve, reject) => {
const timer = setTimeout(
Expand Down
15 changes: 0 additions & 15 deletions patches/vite@8.1.5.patch

This file was deleted.

Loading
Loading