Context API exposure in handlers and WorkerEntrypoint
The Context API is exposed as the third parameter in all handlers, including the fetch() handler (fetch(request, env, ctx)), and as a class property this.ctx in the WorkerEntrypoint class. The Context API is available strictly in stateless contexts, not in Durable Objects. Durable Objects have a different object called Durable Object State available as this.ctx inside a Durable Object class, which provides some of the same functionality.
ctx.waitUntil(): extend Worker lifetime for background work
ctx.waitUntil() extends the lifetime of a Worker by accepting a Promise that the Workers runtime continues executing even after the response is returned. It allows work to run after the response is sent without blocking the response. Use cases include firing events to external analytics providers and putting items into cache. For Workers Analytics Engine, waitUntil is not needed. An async call that is neither awaited nor passed to ctx.waitUntil() can be canceled when invocation ends.
ctx.waitUntil() time limit: 30 seconds after invocation end
For HTTP-triggered Workers, ctx.waitUntil() extends execution for up to 30 seconds after the response is sent or the client disconnects. This is not a limit on total wall time. The time limit is shared across all waitUntil() calls within the same request. If Promises do not settle after 30 seconds, they are canceled and a warning is logged: 'waitUntil() tasks did not complete within the allowed time after invocation end and have been cancelled.' If work cannot finish within the limit, send messages to a Queue for processing in a separate consumer Worker.
ctx.waitUntil() can be called multiple times
You can call ctx.waitUntil() multiple times. Similar to Promise.allSettled, even if a promise passed to one waitUntil call is rejected, promises passed to other waitUntil() calls will still continue to execute.
Node.js APIs provided in two forms
Cloudflare Workers provides a subset of Node.js APIs in two forms: (1) as built-in APIs provided by the Workers Runtime, which are mostly full implementations of corresponding Node.js APIs with some partially supported, and (2) as polyfill shim implementations that Wrangler adds to Worker code, allowing imports but calling API methods will throw errors.
Node.js compatibility enabled by default for 2026-08-04 or later
For compatibility dates of 2026-08-04 or later, Workers enables both nodejs_compat and nodejs_compat_v2 by default. Built-in Node.js APIs and polyfills are available without additional configuration, and these flags are not used because the compatibility date enables the same behavior.
nodejs_compat flag for compatibility dates 2024-09-23 through 2026-08-03
For compatibility dates from 2024-09-23 through 2026-08-03, add the nodejs_compat compatibility flag to the Wrangler configuration file to opt in to Node.js API support.
Disabling Node.js compatibility for 2026-08-04 or later
To turn off Node.js compatibility completely with a compatibility date of 2026-08-04 or later, remove positive flags if present and add both no_nodejs_compat and no_nodejs_compat_v2 flags.
Supported Node.js APIs in Workers Runtime
The following Node.js APIs are natively supported (🟢) or partially supported (🟡) in the Workers Runtime: Assertion testing (supported), Asynchronous context tracking (supported), Buffer (supported), Console (partially supported), Crypto (supported), Debugger (supported via Chrome DevTools), Diagnostics Channel (supported), DNS (partially supported), Errors (supported), Events (supported), File system (supported), Globals (supported), HTTP (supported), HTTPS (supported), Module (partially supported), Net (supported), OS (partially supported), Path (supported), Performance hooks (partially supported), Process (supported), Punycode (supported), Query strings (supported), Stream (supported), String decoder (supported), Test runner (partially supported), Timers (supported), TLS/SSL (partially supported), URL (supported), Utilities (supported), Web Crypto API (supported), Web Streams API (supported), Zlib (supported).
Non-functional stub modules for Node.js APIs
Some Node.js modules are available as non-functional stubs that can be imported or required but do not provide working implementations. These stubs are enabled automatically only when the nodejs_compat compatibility flag is enabled and the Worker's compatibility date is on or after a specified date. Earlier enablement or later disablement can be controlled with corresponding enable and disable flags.
Node.js API polyfills via Wrangler
Node.js APIs not yet supported in the Workers runtime are polyfilled via Wrangler using unenv. When the nodejs_compat compatibility flag is enabled and the compatibility date is 2024-09-23 or later, Wrangler automatically injects polyfills into Worker code. Calling polyfilled methods either noop or throw an error with a message like '[unenv] <method name> is not implemented yet!'.
Enable only AsyncLocalStorage with nodejs_als flag
To enable only the Node.js AsyncLocalStorage API without enabling other Node.js compatibility features, use the nodejs_als compatibility flag in the Wrangler configuration.
Node.js implementation versions
Native implementations of Node.js APIs in Workers are intended to match the implementation in the Current release of Node.js unless otherwise specified.
node:crypto module availability in Workers
The node:crypto module provides cryptographic functionality including wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. All node:crypto APIs are fully supported in Cloudflare Workers.
node:crypto generateKeyPair limitations
The generateKeyPair and generateKeyPairSync functions do not support DSA or DH key pairs in Cloudflare Workers.
node:crypto argon2 not supported
The argon2 and argon2Sync functions are not supported in Cloudflare Workers.
node:crypto ed448 and x448 curves not supported
The ed448 and x448 curves are not supported in Cloudflare Workers.
FIPS mode cannot be manually controlled in node:crypto
It is not possible to manually enable or disable FIPS mode in Cloudflare Workers when using the node:crypto module.
WebCrypto API available without compatibility flag
The WebCrypto API is available within Cloudflare Workers and does not require the nodejs_compat compatibility flag.