workerd error: crypto.subtle digest not available in local dev
Fixes crypto.subtle.digest failing in local workerd development while working when deployed. This skill walks through checking the wrangler version, setting a current compatibility date, and restarting dev so the local runtime enables Web Crypto digest. Use it when hashing or signature verification throws that digest is unavailable only in wrangler dev.
Fix crypto.subtle digest not available in local dev
TL;DR
Update wrangler and set a recent compatibility_date in wrangler.toml, then fully restart wrangler dev. Older local runtimes gate the Web Crypto digest behind a compatibility flag that modern dates enable by default. If you test outside the worker runtime (plain Node test runner), run the tests inside the Cloudflare Workers vitest pool instead so crypto matches production.
Verbatim error
workerd error: crypto.subtle digest not available in local devSteps
- Check your wrangler version with
npx wrangler --version. Expected: a current 4.x release; anything much older is the likely cause. - Update it: install the latest wrangler as a dev dependency (or your package manager's equivalent). Expected: install completes with no blocking peer-dependency errors.
- In wrangler.toml set
compatibility_dateto a recent date, for examplecompatibility_date = "2026-09-01". Expected: the file parses andwrangler devstarts without a duplicate-key or invalid-date error. - Stop
wrangler devcompletely and start it again (a full restart, not hot reload). Expected: dev boots cleanly. - Add a temporary log early in your handler:
console.log(typeof crypto.subtle.digest). Expected: it printsfunctionin the dev console. - If the failure is in unit tests, run them with the Cloudflare Workers vitest pool instead of plain Node. Expected: the digest tests pass locally.
Use this when
crypto.subtle.digestthrows or is undefined inwrangler devbut works after deploy- Hashing, HMAC, or signature verification fails only in local development
typeof crypto.subtle.digestlogsundefinedlocally
Not for this skill when
- Crypto works locally but fails when deployed (that is a deploy-config issue, not this one)
- You need an unsupported algorithm (Workers supports the standard SHA family, HMAC, AES-GCM, P-256/P-384/P-521, Ed25519)
- The failure is
randomUUIDorgetRandomValuesrather thandigest
Variant phrasings
- miniflare crypto.subtle undefined
- workerd digest is not a function
- "crypto.subtle not available" wrangler dev
- SubtleCrypto digest missing in local workers runtime
Why it happens
workerd gates API surface behind compatibility dates and flags. A very old default compatibility_date leaves the Web Crypto subprovider disabled in the local runtime, while production workers run with newer defaults. Setting a recent compatibility date and restarting opts the local runtime into the same behavior as production.
Edge cases
- A
compatibility_datein the future makes wrangler reject the config, so use a real past date. - Changing the date can flip other runtime behaviors, so redeploy and smoke-test after the change.
- Some JWT libraries call
digestat import time; in a plain Node test runner that import fails, so test inside the Cloudflare Workers vitest pool.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst7JdIVH-arkCHzemhcs7wQ
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.