Upgrade vitest 2 → 4, pool-workers 0.5 → 0.15, patch Hono CVEs, add CI#39
Merged
Conversation
Resolves two npm audit advisories: - Critical: HTML injection in hono/jsx SSR via attribute names (GHSA-458j-xx4x-4375) - High: middleware bypass via repeated slashes in serveStatic (GHSA-wmmm-f939-6g9c) `npm audit --omit=dev` now reports 0 vulnerabilities. Remaining advisories are all in devDependencies (miniflare/undici/vite/esbuild) and don't ship to production. Refs #38. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous test suite reported 462/477 passing with 3 unhandled errors —
all from a known @cloudflare/vitest-pool-workers v0.5 bug where the storage
isolation snapshot asserts every persist file ends in `.sqlite`, but
SQLite-backed Durable Objects in WAL mode also produce `.sqlite-shm` and
`.sqlite-wal` files. Upstream fix landed in pool-workers 0.13, which
requires vitest 4.
Changes:
- Bump vitest 2 → 4, @cloudflare/vitest-pool-workers 0.5 → 0.15+; add
@types/node (no longer transitive). Node 22 required (.nvmrc + CI).
- Migrate vitest.config.ts from `defineWorkersConfig` (now removed) to
`defineConfig({ plugins: [cloudflareTest({...})] })`. Same options shape,
different wiring.
- tsconfig: types entry is now `@cloudflare/vitest-pool-workers/types`
(new export path); add `node` to surface Error.captureStackTrace and
`node:crypto` typings.
- src/types/index.ts: keep `JOB_STATUS: DurableObjectNamespace` (no
generic). The class uses the older `implements DurableObject` interface
and doesn't satisfy the new `Rpc.DurableObjectBranded` constraint;
worker-configuration.d.ts already carries the precise generic.
- 6 test files: `as Env` → `as unknown as Env`. Workers-types' DO generic
is stricter now and the spread `{...env}` produces a precise
`DurableObjectNamespace<JobStatusDO>` that doesn't assign to the loose
`Env` cast.
- test/{api,consumer}.test.ts: `clearTestData` now also wipes the
`episodes:` prefix so the episode index key (`episodes:index`) doesn't
carry stale entries across tests. Fixes 1 latent failure.
- test/consumer.test.ts: `createMockBatch` accepts an `attempts` option.
7 failure-case tests now pass `attempts: 3` so the consumer's
`attempts >= maxAttempts` check trips and marks the job failed —
previously these tests were exercising the retry path while asserting
failed state, which is impossible. The pool-workers tooling bug was
masking the contradiction.
- .github/workflows/ci.yml: run typecheck + tests on push/PR (Node 22).
Result: 477/477 tests passing (was 462), typecheck clean, exit 0.
Production deps: 0 vulnerabilities (Hono CVE patched in prior commit).
Closes #38.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #38. Three production-hardening items in one branch:
Hono CVE patch (
4.11.1→4.12.16) — fixes a critical HTML injection inhono/jsxSSR and a high-severity middleware bypass via repeated slashes inserveStatic.npm audit --omit=devnow clean.vitest 4 + pool-workers 0.15 upgrade — the previous baseline reported 462/477 passing with 3 unhandled errors, all from a known pool-workers 0.5 bug where the storage isolation snapshot asserts every persist file ends in
.sqlite, but SQLite-backed Durable Objects in WAL mode also produce.sqlite-shm/.sqlite-wal. Upstream fix landed in pool-workers 0.13 (vitest 4 only). Migrating fixed all 3 tooling errors and exposed 7 latent test bugs that were masked by the broken isolation. Now 477/477 passing.Add CI (
.github/workflows/ci.yml) — runstypecheckandnpm teston push to main + every PR. Node 22 (required by vitest 4).What's in the upgrade
vitest.config.ts—defineWorkersConfig(removed in v4) →defineConfig({ plugins: [cloudflareTest({...})] })tsconfig.json— types entry is now@cloudflare/vitest-pool-workers/types;nodeadded to surfaceError.captureStackTraceandnode:cryptosrc/types/index.ts— keepJOB_STATUS: DurableObjectNamespace(no generic).JobStatusDOuses the oldimplements DurableObjectinterface and doesn't satisfy the newRpc.DurableObjectBrandedconstraintas Env→as unknown as Env(DO generic is stricter now)test/{api,consumer}.test.ts—clearTestDatanow wipes theepisodes:prefix so the index key (episodes:index) doesn't carry stale entries across teststest/consumer.test.ts—createMockBatchtakes{ attempts }; 7 failure-case tests now passattempts: 3so the consumer'sattempts >= maxAttemptscheck trips and marks the job failed (previously these were exercising the retry path while asserting failed state, which is impossible — pool-workers tooling bug masked the contradiction).nvmrc→22Test plan
npm run typecheckexit 0npx vitest run→ 36/36 files, 477/477 tests, exit 0npm audit --omit=dev→ 0 vulnerabilities🤖 Generated with Claude Code