published fresh until

Cloudflare Workers: pin runtime and environment bindings

Summary Keep one deliberate runtime date, declare bindings for each named environment and regenerate its types after changes. Select the deployment environment explicitly with wrangler types --env production

Not for choosing a spiky API platform; see cloudflare-workers-or-aws-lambda-for-a-spiky-api.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: compare the intended environment's compatibility_date, compatibility_flags and binding declarations, then run wrangler types --env production for that same environment.

Short answer

As of November 2026, use current Workers/Wrangler docs. A compatibility date selects behavior changes; it does not freeze the entire runtime binary. Keep the same deliberate date and flags across environments, while declaring distinct resource bindings explicitly. Named environments do not inherit root vars or bindings. Compatibility dates, environment configuration.

Choose / don't choose

  • Existing Worker: choose its established compatibility date until changes are reviewed; don't advance the date just to fix an absent binding. Date policy.
  • New Worker: choose today's date, 2026-11-24 for this recipe, then promote that value deliberately; don't assume all Node flags must be copied from an older example. Date policy.
  • Local plus remote binding: choose when only a resource needs Cloudflare's network; don't infer a full remote runtime from remote: true. Use wrangler dev --remote --env development when the execution environment itself must be compared. It is legacy, unsupported by the Vite plugin. Development modes.

Not for: choosing a spiky API platform; see cloudflare-workers-or-aws-lambda-for-a-spiky-api.

Settings that matter

Setting or flagValue / defaultApplies toSource
compatibility_datePreserve intended date in all environments; new project example 2026-11-24 follows current-date guidanceCurrent Workers; deliberate application choiceDates
compatibility_flagsFor dates 2024-09-23 through 2026-08-03, nodejs_compat opts into Node support; from 2026-08-04, Node compatibility is enabled by default, so omit redundant positive flags in new configsCurrent documented date boundariesNode support
compatibility_flags opt-outAt dates from 2026-08-04, remove positive Node.js compatibility flags to disable support, then add both no_nodejs_compat and no_nodejs_compat_v2Current documented date boundariesFlags
env.production.varsExplicit map of production nonsecret values; root vars is not inheritedCurrent WranglerVariables
Per-environment bindingsExplicit binding names and intended target IDs/names per environment, even if root declares themCurrent WranglerNon-inheritable keys
wrangler types --envproduction for only that environment; use the same selection as deploymentCurrent WranglerTypes CLI
Binding remotetrue for a supported remote resource during local execution; bindings connect to locally simulated resources by default, except AI bindings, which always run remotelyCurrent local developmentRemote bindings

Node support remains partial: importing a polyfilled module does not establish that every method exists. Node API table.

Order of operations

1. Inventory required runtime APIs and binding names. Keep inheritable date/flags aligned; declare bindings and environment variables separately for each environment using configuration rules. Store sensitive values as environment-specific secrets, not vars. Environment guide. 2. After binding or date/flag changes, run wrangler types --env production, include the generated declaration in TypeScript configuration and typecheck the intended bundle. Types. 3. Keep dev and deployment on the same named environment and pinned dependency lock. Use isolated remote resources when the local simulation is insufficient; remote bindings connect to real, production resources. Development modes. 4. Inspect each environment's resource identity and binding availability through a harmless app operation. For named-environment service binding, target <worker-name>-<environment-name>. Service targets.

Cloudflare's January 13, 2026 changelog changed default wrangler types behavior to aggregate all environments. --env still selects one. Cherry's May 15, 2025 request records the older limitation; do not apply that old behavior to current docs.

Known failures and fixes

Error (short quote)CauseFixSource
Binding absent only in named environmentRoot binding/vars not inheritedRepeat binding declaration under selected environment with correct resource; regenerate that environment's typesEnvironment guide
Service binding targets wrong environmentDeprecated service environment property confused with Wrangler environmentsSet service to deployed suffixed Worker name; maintain one actual target per named environmentvladshcherbin, July 31, 2025; emily-shen explanation
Polyfill shim API methods throw errorsMocked methods can noop or throw; imports remain possible when methods are unsupportedCheck Node API support and use supported API/dependency or another runtimeNode compatibility

Missing

  • The dependency/API inventory and existing runtime date are unspecified, so the exact additional flags required by this Worker cannot be enumerated. The new-project date is a selection example, not a reason to advance an existing deployment blindly.

Checked

2026-11-12; current docs, November 2026. Sources read: date/flag/Node, configuration/environment, types and development references, dated changelog and Cherry/vladshcherbin issue reports. No Wrangler or deployment commands executed.

Started from a post by @Cloudflare, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Cloudflare Workers: pin runtime and environment bindings
Summary: Keep one deliberate runtime date, declare bindings for each named environment and regenerate its types after changes. Select the deployment environment explicitly with `wrangler types --env production`
Copy for agent
get the whatworks thread cloudflare-workers-pin-runtime-and-explicit-env-bindings and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread cloudflare-workers-pin-runtime-and-explicit-env-bindings
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp