- Compatibility flags·续7
- Streams Constructors
- Compliant TransformStream constructor
- CommonJS modules do not export a module namespace
- Do not throw from async functions
- New URL parser implementation
- R2 bucket list respects the include option
- Do not substitute null on TypeError
- Minimal subrequests
- Global navigator
- Do not use the Custom Origin Trust Store for external subrequests
- Setters/getters on API object prototypes
- Durable Object stub.fetch() requires a full URL
- fetch() improperly interprets unknown protocols as HTTP
- Streams BYOB reader detaches buffer
- FormData parsing supports File
- HTMLRewriter handling of <esi:include>
Compatibility flags·续7
The following stubs are enabled automatically only when
nodejs_compatis enabled and your Worker's compatibility date is on or after the date shown:
Stub module Enabled with nodejs_compaton or afterEnable flag Disable flag node:http2↗︎2025-09-01enable_nodejs_http2_moduledisable_nodejs_http2_modulenode:vm↗︎2025-10-01enable_nodejs_vm_moduledisable_nodejs_vm_modulenode:cluster↗︎2025-12-04enable_nodejs_cluster_moduledisable_nodejs_cluster_modulenode:domain↗︎2025-12-04enable_nodejs_domain_moduledisable_nodejs_domain_modulenode:trace_events↗︎2025-12-04enable_nodejs_trace_events_moduledisable_nodejs_trace_events_modulenode:wasi↗︎2025-12-04enable_nodejs_wasi_moduledisable_nodejs_wasi_modulenode:_stream_wrap2026-01-29enable_nodejs_stream_wrap_moduledisable_nodejs_stream_wrap_modulenode:dgram↗︎2026-01-29enable_nodejs_dgram_moduledisable_nodejs_dgram_modulenode:inspector↗︎2026-01-29enable_nodejs_inspector_moduledisable_nodejs_inspector_modulenode:sqlite↗︎2026-01-29enable_nodejs_sqlite_moduledisable_nodejs_sqlite_modulenode:child_process↗︎2026-03-17enable_nodejs_child_process_moduledisable_nodejs_child_process_modulenode:readline↗︎2026-03-17enable_nodejs_readline_moduledisable_nodejs_readline_modulenode:repl↗︎2026-03-17enable_nodejs_repl_moduledisable_nodejs_repl_modulenode:tty↗︎2026-03-17enable_nodejs_tty_moduledisable_nodejs_tty_modulenode:v8↗︎2026-03-17enable_nodejs_v8_moduledisable_nodejs_v8_modulenode:worker_threads↗︎2026-03-17enable_nodejs_worker_threads_moduledisable_nodejs_worker_threads_moduleWhen enabling
nodejs_compat, we recommend using the latest version of Wrangler CLI, and the latest compatibility date, in order to maximize compatibility. Some older versions of Wrangler inject additional polyfills that are no longer necessary when your Worker uses a more recent compatibility date, because they are provided by the Workers runtime.For compatibility dates of
2026-08-04or later,nodejs_compatandnodejs_compat_v2are not used because the compatibility date enables the same behavior. Existing projects do not need to remove these flags when updating their compatibility date. To turn off Node.js compatibility completely, remove the positive flags if present. Then add bothno_nodejs_compatandno_nodejs_compat_v2.If you see errors using a particular npm package on Workers, you should first try updating your compatibility date and use the latest version of Wrangler CLI or the Cloudflare Vite Plugin. If you still encounter issues, please report them by opening a GitHub issue ↗︎.
Streams Constructors
Default as of 2022-11-30 Flag to enable streams_enable_constructorsFlag to disable streams_disable_constructorsAdds the work-in-progress
new ReadableStream()andnew WritableStream()constructors backed by JavaScript underlying sources and sinks.Compliant TransformStream constructor
Default as of 2022-11-30 Flag to enable transformstream_enable_standard_constructorFlag to disable transformstream_disable_standard_constructorPreviously, the
new TransformStream()constructor was not compliant with the Streams API standard. Use thetransformstream_enable_standard_constructorto opt-in to the backwards-incompatible change to make the constructor compliant. Must be used in combination with thestreams_enable_constructorsflag.CommonJS modules do not export a module namespace
Default as of 2022-10-31 Flag to enable export_commonjs_defaultFlag to disable export_commonjs_namespaceCommonJS modules were previously exporting a module namespace (an object like
{ default: module.exports }) rather than exporting only themodule.exports. When this flag is enabled, the export is fixed.Do not throw from async functions
Default as of 2022-10-31 Flag to enable capture_async_api_throwsFlag to disable do_not_capture_async_api_throwsThe
capture_async_api_throwscompatibility flag will ensure that, in conformity with the standards API, async functions will only ever reject if they throw an error. The inversedo_not_capture_async_api_throwsflag means that async functions which contain an error may throw that error synchronously rather than rejecting.New URL parser implementation
Default as of 2022-10-31 Flag to enable url_standardFlag to disable url_originalThe original implementation of the
URL↗︎ API in Workers was not fully compliant with the WHATWG URL Standard ↗︎, differing in several ways, including:
- The original implementation collapsed sequences of multiple slashes into a single slash:
new URL("https://example.com/a//b").toString() === "https://example.com/a/b"- The original implementation would throw"TypeError: Invalid URL string."if it encountered invalid percent-encoded escape sequences, likehttps://example.com/a%%b. - The original implementation would percent-encode or percent-decode certain content differently:
new URL("https://example.com/a%40b?c d%20e?f").toString() === "https://example.com/a@b?c+d+e%3Ff"- The original implementation lacked more recently implementedURLfeatures, likeURL.canParse()↗︎.Set the compatibility date of your Worker to a date after
2022-10-31or enable theurl_standardcompatibility flag to opt-in the fully spec compliantURLAPI implementation.Refer to the
response_redirect_url_standardcompatibility flag , which affects the URL implementation used inResponse.redirect().
R2bucketlistrespects theincludeoption
Default as of 2022-08-04 Flag to enable r2_list_honor_includeWith the
r2_list_honor_includeflag set, theincludeargument to R2listoptions is honored. With an older compatibility date and without this flag, theincludeargument behaves implicitly asinclude: ["httpMetadata", "customMetadata"].Do not substitute
nullonTypeError
Default as of 2022-06-01 Flag to enable dont_substitute_null_on_type_errorFlag to disable substitute_null_on_type_errorThere was a bug in the runtime that meant that when being passed into built-in APIs, invalid values were sometimes mistakenly coalesced with
null. Instead, aTypeErrorshould have been thrown. Thedont_substitute_null_on_type_errorfixes this behavior so that an error is correctly thrown in these circumstances.Minimal subrequests
Default as of 2022-04-05 Flag to enable minimal_subrequestsFlag to disable no_minimal_subrequestsWith the
minimal_subrequestsflag set,fetch()subrequests sent to endpoints on the Worker's own zone (also called same-zone subrequests) have a reduced set of features applied to them. In general, these features should not have been initially applied to same-zone subrequests, and very few user-facing behavior changes are anticipated. Specifically, Workers might observe the following behavior changes with the new flag:
- Response bodies will not be opportunistically gzipped before being transmitted to the Workers runtime. If a Worker reads the response body, it will read it in plaintext, as has always been the case, so disabling this prevents unnecessary decompression. Meanwhile, if the Worker passes the response through to the client, Cloudflare's HTTP proxy will opportunistically gzip the response body on that side of the Workers runtime instead. The behavior change observable by a Worker script should be that some
Content-Encoding: gzipheaders will no longer appear.- Automatic Platform Optimization may previously have been applied on both the Worker's initiating request and its subrequests in some circumstances. It will now only apply to the initiating request.
- Link prefetching will now only apply to the Worker's response, not responses to the Worker's subrequests.
Global
navigator
Default as of 2022-03-21 Flag to enable global_navigatorFlag to disable no_global_navigatorWith the
global_navigatorflag set, a new globalnavigatorproperty is available from within Workers. Currently, it exposes only a singlenavigator.userAgentproperty whose value is set to'Cloudflare-Workers'. This property can be used to reliably determine whether code is running within the Workers environment.Do not use the Custom Origin Trust Store for external subrequests
Default as of 2022-03-08 Flag to enable no_cots_on_external_fetchFlag to disable cots_on_external_fetchThe
no_cots_on_external_fetchflag disables the use of the Custom Origin Trust Store when making external (grey-clouded) subrequests from a Cloudflare Worker.Setters/getters on API object prototypes
Default as of 2022-01-31 Flag to enable workers_api_getters_setters_on_prototypeFlag to disable workers_api_getters_setters_on_instanceOriginally, properties on Workers API objects were defined as instance properties as opposed to prototype properties. This broke subclassing at the JavaScript layer, preventing a subclass from correctly overriding the superclass getters/setters. This flag controls the breaking change made to set those getters/setters on the prototype template instead.
This changes applies to:
AbortSignalAbortControllerBlobBodyDigestStreamEventFileRequestReadableStreamReadableStreamDefaultReaderReadableStreamBYOBReaderResponseTextDecoderTextEncoderTransformStreamURLWebSocketWritableStreamWritableStreamDefaultWriterDurable Object
stub.fetch()requires a full URL
Default as of 2021-11-10 Flag to enable durable_object_fetch_requires_full_urlFlag to disable durable_object_fetch_allows_relative_urlOriginally, when making a request to a Durable Object by calling
stub.fetch(url), a relative URL was accepted as an input. The URL would be interpreted relative to the placeholder URLhttp://fake-host, and the resulting absolute URL was delivered to the destination object'sfetch()handler. This behavior was incorrect — full URLs were meant to be required. This flag makes full URLs required.
fetch()improperly interprets unknown protocols as HTTP
Default as of 2021-11-10 Flag to enable fetch_refuses_unknown_protocolsFlag to disable fetch_treats_unknown_protocols_as_httpOriginally, if the
fetch()function was passed a URL specifying any protocol other thanhttp:orhttps:, it would silently treat it as if it werehttp:. For example,fetch()would appear to acceptftp:URLs, but it was actually making HTTP requests instead.Note that Cloudflare Workers supports a non-standard extension to
fetch()to make it support WebSockets. However, when making an HTTP request that is intended to initiate a WebSocket handshake, you should still usehttp:orhttps:as the protocol, notws:norwss:.The
ws:andwss:URL schemes are intended to be used together with thenew WebSocket()constructor, which exclusively supports WebSocket. The extension tofetch()is designed to support HTTP and WebSocket in the same request (the response may or may not choose to initiate a WebSocket), and so all requests are considered to be HTTP.Streams BYOB reader detaches buffer
Default as of 2021-11-10 Flag to enable streams_byob_reader_detaches_bufferFlag to disable streams_byob_reader_does_not_detach_bufferOriginally, the Workers runtime did not detach the
ArrayBuffers from user-provided TypedArrays when using the BYOB reader'sread()method, as required by the Streams spec, meaning it was possible to inadvertently reuse the same buffer for multipleread()calls. This change makes Workers conform to the spec.User code should never try to reuse an
ArrayBufferthat has been passed into a BYOB reader'sread()method. Instead, user code can reuse theArrayBufferbacking the result of theread()promise, as in the example below.
// Consume and discard `readable` using a single 4KiB buffer.
let reader = readable.getReader({ mode: "byob" });
let arrayBufferView = new Uint8Array(4096);
while (true) {
let result = await reader.read(arrayBufferView);
if (result.done) break;
// Optionally something with `result` here.
// Re-use the same memory for the next `read()` by creating
// a new Uint8Array backed by the result's ArrayBuffer.
arrayBufferView = new Uint8Array(result.value.buffer);
}
The more recently added extension method
readAtLeast()will always detach theArrayBufferand is unaffected by this feature flag setting.
FormDataparsing supportsFile
Default as of 2021-11-03 Flag to enable formdata_parser_supports_filesFlag to disable formdata_parser_converts_files_to_stringsThe
FormDataAPI ↗︎ is used to parse data (especially HTTP request bodies) inmultipart/form-dataformat.Originally, the Workers runtime's implementation of the
FormDataAPI incorrectly converted uploaded files to strings. Therefore,formData.get("filename")would return a string containing the file contents instead of aFileobject. This change fixes the problem, causing files to be represented usingFileas specified in the standard.
HTMLRewriterhandling of<esi:include>
Flag to enable html_rewriter_treats_esi_include_as_void_tagThe HTML5 standard defines a fixed set of elements as void elements, meaning they do not use an end tag:
<area>,<base>,<br>,<col>,<command>,<embed>,<hr>,<img>,<input>,<keygen>,<link>,<meta>,<param>,<source>,<track>, and<wbr>.
