Worker Compatibility Date, nodejs_compat, and Node.js Runtime APIs
How Cloudflare Workers compatibility_date and compatibility_flags enable Node.js APIs, what changes by date, and how to configure or disable them.
This page summarizes Cloudflare Workers documentation on compatibility dates, compatibility flags, and Node.js compatibility (nodejs_compat). Together they control which runtime behavior your Worker gets—including whether node:crypto, node:buffer, node:fs, node:http, and npm packages that depend on them work without extra setup.
compatibility_date: what it controls on a Worker
Section titled “compatibility_date: what it controls on a Worker”A compatibility date is how you opt into runtime updates without silently changing behavior for Workers already in production.
Cloudflare regularly updates the Workers runtime. These updates apply to all Workers globally and should never cause a Worker that is already deployed to stop functioning. Sometimes, though, some changes may be backwards-incompatible. In particular, there might be bugs in the runtime API that existing Workers may inadvertently depend upon. Cloudflare implements bug fixes that new Workers can opt into while existing Workers will continue to see the buggy behavior to prevent breaking deployed Workers.
The compatibility date and flags are how you, as a developer, opt into these runtime changes. Compatibility flags will often have a date in which they are enabled by default, and so, by specifying a compatibility_date for your Worker, you can quickly enable all of these various compatibility flags up to, and including, that date.
— Cloudflare, Compatibility dates
When you raise the date and redeploy, you inherit every flag whose default cutover is on or before that date. The new date takes effect on the next npx wrangler deploy. You do not have to update the date; old dates remain supported. Staying current is still useful because some features only appear for recent dates, and docs often describe the latest date only—see Compatibility dates and Workers Best Practices.
How to set compatibility_date in Wrangler, the dashboard, or the API
Section titled “How to set compatibility_date in Wrangler, the dashboard, or the API”In Wrangler configuration, set compatibility_date to a calendar day (many examples use a current date such as 2026-10-29):
{ "compatibility_date": "2026-10-29"}Dashboard-created Workers get today’s date automatically; you can change it under Workers settings. Via the Workers Script API or Versions API, omitting compatibility_date defaults to 2021-11-02—explicitly set a current date for new uploads. Miniflare uses the same idea locally (compatibilityDate in config). The Dynamic Workers API reference treats compatibilityDate like Wrangler’s compatibility_date.
compatibility_flags: enable, disable, or test runtime features
Section titled “compatibility_flags: enable, disable, or test runtime features”Compatibility flags turn specific runtime changes on or off independently of waiting for a date—useful to preview upcoming behavior or keep legacy semantics while moving the date forward.
Compatibility flags enable specific features. They can be useful if you want to help the Workers team test upcoming changes that are not yet enabled by default, or if you need to hold back a change that your code depends on but still want to apply other compatibility changes.
Compatibility flags will often have a date in which they are enabled by default, and so, by specifying a compatibility_date for your Worker, you can quickly enable all of these various compatibility flags up to, and including, that date.
— Cloudflare, Compatibility flags
Set compatibility_flags in Wrangler, the dashboard, or upload metadata—same pattern as dates (Compatibility flags). Individual flags often pair an enable name with a no_* variant (for example spec_compliant_dispatch_exceptions vs no_spec_compliant_dispatch_exceptions).
| Concern | Enable / default | Opt out or legacy |
|---|---|---|
| Node.js built-ins | nodejs_compat (default with date ≥ 2026-08-04) |
no_nodejs_compat, no_nodejs_compat_v2 |
| Post-quantum Web Crypto (ML-KEM, ML-DSA) | webcrypto_modern_algorithms |
Not default; add explicitly |
Spec-compliant dispatchEvent() errors |
Default with date ≥ 2026-09-15 |
no_spec_compliant_dispatch_exceptions |
MessageChannel at global scope |
Default with date ≥ 2025-08-15 |
no_expose_global_message_channel |
Only AsyncLocalStorage |
nodejs_als without full compat |
See AsyncLocalStorage |
nodejs_compat: when Node.js APIs are on by default
Section titled “nodejs_compat: when Node.js APIs are on by default”Many teams enable Node.js compatibility so npm drivers and libraries that expect node:* modules run on the edge. Legacy --node-compat / node_compat config is deprecated in favor of the nodejs_compat flag (Wrangler deprecations).
Workers now enable the nodejs_compat and nodejs_compat_v2 compatibility flags by default for compatibility dates of 2026-08-04 or later. These flags are not used for these compatibility dates because the compatibility date enables the same behavior.
This means all Node.js built-in APIs supported by the Workers runtime are available by default, including node:crypto, node:buffer, node:stream, node:net, node:dns, node:fs, node:http, and more. npm packages that depend on these APIs will work without additional configuration.
— Cloudflare, Node.js compatibility is now enabled by default
For compatibility dates before 2026-08-04, add nodejs_compat to compatibility_flags (Node.js compatibility flag, Connect to MongoDB tutorial). Between 2024-09-23 and 2026-08-03, nodejs_compat also enables nodejs_compat_v2 unless you set no_nodejs_compat_v2 (Compatibility flags).
Turning Node.js compatibility off on a recent compatibility date
Section titled “Turning Node.js compatibility off on a recent compatibility date”To run without Node.js APIs on a date ≥ 2026-08-04, remove positive nodejs_compat entries and set both disable flags (Node.js compatibility):
{ "compatibility_date": "2026-10-29", "compatibility_flags": [ "no_nodejs_compat", "no_nodejs_compat_v2" ]}Wrangler, Miniflare, the Cloudflare Vite plugin, and Vitest Pool Workers ignore redundant nodejs_compat flags when the date already implies the same behavior (changelog).
What Node.js compatibility actually provides
Section titled “What Node.js compatibility actually provides”Workers expose Node.js in two layers (Node.js compatibility):
- Runtime APIs — native or partial implementations in the isolate (for example Buffer, node:crypto, node:fs).
- Wrangler polyfills — when
nodejs_compatis on and the date is2024-09-23or later, Wrangler may inject unenv shims; calling unimplemented methods can noop or throw[unenv] <method> is not implemented yet!.
Native APIs vs import-only stubs
Section titled “Native APIs vs import-only stubs”The Node.js compatibility overview lists APIs marked supported or partially supported (DNS, TLS, node:http, and others). Some modules exist only as non-functional stubs so packages that probe for imports can load; do not call them in application code. Stubs such as node:child_process, node:worker_threads, and node:vm unlock on specific dates or via enable_nodejs_*_module / disable_nodejs_*_module flags (Compatibility flags).
Extra flags for HTTP, file system, and HTTP servers
Section titled “Extra flags for HTTP, file system, and HTTP servers”Several modules need both a sufficient compatibility date and sometimes extra flags:
| API | Typical requirement |
|---|---|
node:fs virtual FS |
nodejs_compat + date ≥ 2025-09-01, or enable_nodejs_fs_module |
node:http / node:https client |
enable_nodejs_http_modules if date < 2025-08-15 |
http.createServer / server APIs |
enable_nodejs_http_server_modules if date < 2025-09-01 |
Client and server node:http / node:https methods wrap the global fetch() API and only work inside an exported fetch (or similar) handler (node:http, node:https). Use httpServerHandler from cloudflare:node to route Worker requests to a createServer listener.
node:fs virtual file system and request-scoped storage
Section titled “node:fs virtual file system and request-scoped storage”With Node.js compatibility, node:fs talks to an in-memory virtual file system (node:fs):
/bundle— read-only files from the Worker bundle (for examplereadFileSync("/bundle/config.json"))./tmp— writable per request; nothing persists to other requests or Workers./dev/null,/dev/random, and related device paths.
The virtual file system is ephemeral with each individual request havig its own isolated temporary file space. Files written to the file system will not persist across requests and will not be shared across requests or across different Workers.
— Cloudflare, The Node.js and Web File System APIs in Workers
Operations are synchronous under the hood even for promise/callback APIs. Limits include 128 MB per file, path length 4096 characters, 48 path segments, and VFS data counts toward the Worker memory limit (node:fs). fs.watch, glob APIs, and real file timestamps are missing or stubbed.
process.cwd() defaults to /bundle (process).
Web Crypto, node:crypto, and choosing an API
Section titled “Web Crypto, node:crypto, and choosing an API”The Web Crypto API (crypto.subtle) is always available and does not require nodejs_compat (Web Crypto). node:crypto needs Node.js compatibility and is largely complete with documented exceptions (no DSA/DH generateKeyPair, no argon2, and others) (node:crypto).
The Web Crypto API differs significantly from the Node.js Crypto API. If you are working with code that relies on the Node.js Crypto API, you can use it by enabling the nodejs_compat compatibility flag.
— Cloudflare, Web Crypto
Post-quantum algorithms (ML-KEM, ML-DSA) are opt-in via webcrypto_modern_algorithms (changelog). Workers Best Practices recommend Web Crypto for new secret-handling code; use node:crypto when porting existing Node libraries.
AsyncLocalStorage and request context in Workers
Section titled “AsyncLocalStorage and request context in Workers”AsyncLocalStorage (node:async_hooks) keeps context across await within a request—typical for request IDs or tracing. Use asyncLocalStorage.run() in fetch and read with getStore(). Workers omit enterWith() and disable(); for thenables, prefer AsyncLocalStorage.snapshot() (AsyncLocalStorage caveats). Enable only ALS with nodejs_als if you do not want full compat (Node.js compatibility).
npm packages that still fail: aliasing and external services
Section titled “npm packages that still fail: aliasing and external services”Not every Node library maps to Workers: packages that need real OS fs, browser window, or unsupported sockets may still break (External Services). Wrangler alias can redirect imports—for example map node-fetch to the built-in fetch, or provide a minimal fs polyfill until runtime support exists.
If errors persist after updating compatibility_date and Wrangler, Cloudflare asks you to report via GitHub issues (linked from the Node.js compatibility flag section).
Common mistakes
Section titled “Common mistakes”- Assuming
/tmpor VFS files persist across requests or Workers. - Using global
setTimeoutfor Node semantics—callnode:timersinstead; timer delays are constrained by Workers I/O timing (timers). - Calling
node:httpget()outside an activefetchhandler (requests may cancel when the handler returns). - Treating stub modules (
node:child_process, etc.) as working APIs. - Using
Buffer.allocUnsafe()—not supported; buffers are zero-filled (Buffer). - Relying on old
dispatchEvent()behavior after raising the date past2026-09-15without testing listeners (spec-compliant dispatch).
How to check this on your site
Section titled “How to check this on your site”- In your Wrangler configuration, confirm
compatibility_dateand anycompatibility_flagsmatch what you expect (for examplenodejs_compatonly if the date is before2026-08-04). - Deploy or run locally with Wrangler or Miniflare using the same
compatibility_dateso local behavior matches production. - Cross-check flag defaults and enable dates on Compatibility flags for APIs you use (
node:fs,node:http, Web Crypto ML algorithms, and others). - In the Cloudflare dashboard Workers settings, verify the published Worker’s compatibility date matches your Wrangler configuration (Compatibility dates).
- You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.