Compatibility flags·续2

Enforce WebSocket close reason byte limit

Default as of 2026-03-03
Flag to enable websocket_close_reason_byte_limit
Flag to disable no_websocket_close_reason_byte_limit

When websocket_close_reason_byte_limit is enabled, WebSocket.close() throws a SyntaxError DOMException if the reason string exceeds 123 bytes when UTF-8 encoded, as required by the WHATWG WebSocket spec ↗︎ and RFC 6455 Section 5.5 ↗︎.

Previously, Workers allowed arbitrarily long close reasons without validation.

Durable Object deleteAll() deletes alarms

Default as of 2026-02-24
Flag to enable delete_all_deletes_alarm
Flag to disable delete_all_preserves_alarm

With the delete_all_deletes_alarm flag set, calling deleteAll() on a Durable Object's storage will delete any active alarm in addition to all stored data. Previously, deleteAll() only deleted user-stored data, and alarms required a separate deleteAlarm() call to remove. This change applies to both KV-backed and SQLite-backed Durable Objects.

TextDecoder replaces lone surrogates

Default as of 2026-02-24
Flag to enable text_decoder_replace_surrogates
Flag to disable disable_text_decoder_replace_surrogates

When text_decoder_replace_surrogates is enabled, the UTF-16le TextDecoder will replace lone surrogates with U+FFFD (the Unicode replacement character) as required by the Encoding Standard ↗︎. Previously, lone surrogates were passed through unchanged, producing non-well-formed strings.

Support iterables as fetch Request/Response body

Default as of 2026-02-19
Flag to enable fetch_iterable_type_support
Flag to disable no_fetch_iterable_type_support

When fetch_iterable_type_support is enabled, sync and async iterables can be passed as the body of a fetch() Request or Response and will be properly iterated over.

Previously, sync iterables like Arrays would be accepted but stringified (e.g., [1, 2, 3] would become "1,2,3"), and async iterables would be treated as regular objects and not iterated at all. With this flag enabled, iterables are properly consumed as streaming body content.

Note that Arrays will now be treated as iterables instead of being stringified, which is a breaking change for code that relied on the previous behavior.

Enable Node.js-compatible global timers

Default as of 2026-02-10
Flag to enable enable_nodejs_global_timers
Flag to disable no_nodejs_global_timers

When enable_nodejs_global_timers is enabled, setTimeout, setInterval, clearTimeout, and clearInterval return Node.js-compatible Timeout objects with methods like refresh(), ref(), unref(), and hasRef(), matching the behavior of node:timers.

This flag requires nodejs_compat to be enabled and is automatically enabled for Workers using a compatibility date of 2026-02-10 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the timer APIs.

Enable node:dgram module

Default as of 2026-01-29
Flag to enable enable_nodejs_dgram_module
Flag to disable disable_nodejs_dgram_module

The enable_nodejs_dgram_module flag enables the node:dgram module stub in Workers.

This flag is automatically enabled for Workers using a compatibility date of 2026-01-29 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the node:dgram API.

Enable node:inspector module

Default as of 2026-01-29
Flag to enable enable_nodejs_inspector_module
Flag to disable disable_nodejs_inspector_module

The enable_nodejs_inspector_module flag enables the node:inspector module stub in Workers.

This flag is automatically enabled for Workers using a compatibility date of 2026-01-29 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the node:inspector API.

Enable node:sqlite module

Default as of 2026-01-29
Flag to enable enable_nodejs_sqlite_module
Flag to disable disable_nodejs_sqlite_module

The enable_nodejs_sqlite_module flag enables the node:sqlite module stub in Workers.

This flag is automatically enabled for Workers using a compatibility date of 2026-01-29 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the node:sqlite API.

Enable node:_stream_wrap module

Default as of 2026-01-29
Flag to enable enable_nodejs_stream_wrap_module
Flag to disable disable_nodejs_stream_wrap_module

The enable_nodejs_stream_wrap_module flag enables the node:_stream_wrap module stub in Workers.

This flag is automatically enabled for Workers using a compatibility date of 2026-01-29 or later when nodejs_compat is enabled.

require() returns default export

Default as of 2026-01-22
Flag to enable require_returns_default_export
Flag to disable require_returns_namespace

When require_returns_default_export is enabled, require() will return the default export of a module if it exists. If the default export does not exist, it falls back to returning a mutable copy of the module namespace object.

This matches the behavior that Node.js uses for require(esm), where the default export is returned when available. This flag is useful for frameworks like Next.js that expect to be able to patch module exports.

Previously, require() always returned the module namespace object (an object like {default: module.exports}).

Duplicate stubs in RPC params instead of transferring ownership

Default as of 2026-01-20
Flag to enable rpc_params_dup_stubs
Flag to disable rpc_params_transfer_stubs

Changes the ownership semantics of RPC stubs embedded in the parameters of an RPC call, fixing compatibility issues with Cap'n Web ↗︎.

When the Workers RPC system was first introduced, RPC stubs that were embedded in the params or return value of some other call had their ownership transferred. That is, the original stub was implicitly disposed, with a duplicate stub being delivered to the destination.

This turns out to compose poorly with another rule: in the callee, any stubs received in the params of a call are automatically disposed when the call returns. These two rules combine to mean that if you proxy a call -- i.e. the implementation of an RPC just makes another RPC call passing along the same params -- then any stubs in the params get disposed twice. Worse, if the eventual recipient of the stub wants to keep a duplicate past the end of the call, this may not work because the copy of the stub in the proxy layer gets disposed anyway, breaking the connection.

For this reason, the pure-JS implementation of Cap'n Web switched to saying that stubs in params do NOT transfer ownership -- they are simply duplicated. This compat flag fixes the Workers Runtime built-in RPC to match Cap'n Web behavior.

One common use case that this fixes is clients that subscribe to callbacks from a Durable Object via Cap'n Web. In this use case, the client app passes a callback function over a Cap'n Web WebSocket to a stateless Worker, which in turn forwards the stub over Workers RPC to a Durable Object. The Durable Object stores a dup() of the stub in order to call it back later to notify the client of events. Unfortunately, before this flag, this didn't work: as soon as the subscribe function itself returned, the Cap'n Web stub in the stateless worker would be disposed (because it was a parameter to a call that returned, and it was not dup()ed within the context of the stateless worker). Hence, when the Durable Object later tried to call the subscription callback, it would receive "Error: RPC stub used after being disposed", despite the fact that it had carefully dup()ed the stub at its end.

Fetch iterable body respects toString/toPrimitive overrides

Default as of 2026-01-15
Flag to enable fetch_iterable_type_support_override_adjustment
Flag to disable no_fetch_iterable_type_support_override_adjustment

When fetch_iterable_type_support_override_adjustment is enabled, objects passed as the body of a fetch() Request or Response that are sync iterable but also have a custom toString or Symbol.toPrimitive method will not be treated as iterables. Instead, they will fall through to being handled as stringified objects, matching the previous behavior for such objects.

This flag refines the behavior introduced by the fetch_iterable_type_support flag and is automatically enabled when fetch_iterable_type_support is enabled after 2026-01-15.

Strip UTF-8 BOM in stream readAllText()

Default as of 2026-01-13
Flag to enable strip_bom_in_read_all_text
Flag to disable do_not_strip_bom_in_read_all_text

When strip_bom_in_read_all_text is enabled, the readAllText() method on streams will strip a leading UTF-8 Byte Order Mark (BOM) if present, matching the expected behavior per web platform standards.

Previously, the BOM was included in the returned string, which could cause unexpected behavior when parsing text content.

Enable node:cluster module

Default as of 2025-12-04
Flag to enable enable_nodejs_cluster_module
Flag to disable disable_nodejs_cluster_module

The enable_nodejs_cluster_module flag enables the node:cluster module stub in Workers.

This flag is automatically enabled for Workers using a compatibility date of 2025-12-04 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the node:cluster API.

Enable node:domain module

Default as of 2025-12-04
Flag to enable enable_nodejs_domain_module
Flag to disable disable_nodejs_domain_module

The enable_nodejs_domain_module flag enables the node:domain module stub in Workers. Note that node:domain is deprecated in Node.js itself.

This flag is automatically enabled for Workers using a compatibility date of 2025-12-04 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the node:domain API.

Enable node:punycode module

Default as of 2025-12-04
Flag to enable enable_nodejs_punycode_module
Flag to disable disable_nodejs_punycode_module

The enable_nodejs_punycode_module flag enables the node:punycode module in Workers. Note that node:punycode is deprecated in Node.js itself.

This flag is automatically enabled for Workers using a compatibility date of 2025-12-04 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the node:punycode API.

Enable node:trace_events module

Default as of 2025-12-04
Flag to enable enable_nodejs_trace_events_module
Flag to disable disable_nodejs_trace_events_module

The enable_nodejs_trace_events_module flag enables the node:trace_events module stub in Workers.

This flag is automatically enabled for Workers using a compatibility date of 2025-12-04 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the node:trace_events API.

Enable node:wasi module

Default as of 2025-12-04
Flag to enable enable_nodejs_wasi_module
Flag to disable disable_nodejs_wasi_module

The enable_nodejs_wasi_module flag enables the node:wasi module stub in Workers.

This flag is automatically enabled for Workers using a compatibility date of 2025-12-04 or later when nodejs_compat is enabled.

See the Node.js documentation ↗︎ for more details about the node:wasi API.

Enable fast JSG struct optimization

Default as of 2025-12-03
Flag to enable enable_fast_jsg_struct
Flag to disable disable_fast_jsg_struct

When enable_fast_jsg_struct is enabled, internal struct types used by Workers runtime APIs are constructed using a more efficient pattern that reduces object creation time.

However, optional fields will be explicitly set to undefined rather than being omitted from the object entirely, which is an observable behavior change. Code that checks for the presence of a property using "key" in obj or Object.hasOwn(obj, "key") may behave differently, since optional fields that were previously absent will now be present with a value of undefined.

To check for a value, prefer obj.key !== undefined over "key" in obj.

Enable ctx.exports

Default as of 2025-11-17
Flag to enable enable_ctx_exports
Flag to disable disable_ctx_exports

This flag enables the ctx.exports API, which contains automatically-configured loopback bindings for your Worker's top-level exports. This allows you to skip configuring explicit bindings for your WorkerEntrypoints and Durable Object namespaces defined in the same Worker.

Automatic tracing

Flag to enable enable_workers_observability_tracing

This flag will enable Workers Tracing by default if you have the following configured in your Wrangler configuration file:

{
    "observability": {
        "enabled": true
    }
}

You can also explictly turn on automatic tracing without the flag and with older compatibility dates by setting the following: