NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #4709 most downloaded on npm
Command-line interface for all things Cloudflare Workers
Last release 2 days ago
02 Oct 2026
Ships on a steady schedule
a new release about every 9 days
Nearly every release is documented
notes for 60 of the last 60 stable releases
119 versions withdrawn
withdrawn after publishing
14 years old
4955 releases · first in 2012
Nothing published for this version
Nothing published for this version
Allows a placement object in the wrangler config with a mode of off or smart to configure Smart placement. Enabling Smart Placement can be done in you
e351afcf Thanks @GregBrimble! - feat: Add support for the undocumented _worker.js/ directory in Pages#3095 133c0423 Thanks @zebp! - feat: add support for placement in wrangler config
Allows a placement object in the wrangler config with a mode of off or smart to configure Smart placement. Enabling Smart Placement can be done in your wrangler.toml like:
[placement]
mode = "smart"
#3140 5fd080c8 Thanks @penalosa! - feat: Support sourcemaps in DevTools
Intercept requests from DevTools in Wrangler to inject sourcemaps and enable folders in the Sources Panel of DevTools. When errors are thrown in your Worker, DevTools should now show your source file in the Sources panel, rather than Wrangler's bundled output.
#2912 5079f476 Thanks @petebacondarwin! - fix: do not render "value of stdout.lastframe() is undefined" if the output is an empty string
Fixes #2907
d0788008 Thanks @dario-piotrowicz! - fix pages building not taking into account the nodejs_compat flag (and improve the related error message)One column per quarter.
### Minor Changes - #3091 `c32f514c` Thanks @edevil! - Added initial commands for integrating with Constellation AI.
Wrangler no longer buffers all assets into memory before uploading. This should prevent out-of-memory errors when publishing sites with many large fil
8818f551 Thanks @mrbbot! - fix: improve Workers Sites asset upload reliability
Too many bulk operations already in progress error.WRANGLER_LOG=debug environment variable. A splash of colour has also been added.This PR lets you search Cloudflare's entire docs via wrangler docs [search term here].
#3004 6d5000a7 Thanks @rozenmd! - feat: teach wrangler docs to use algolia search index
This PR lets you search Cloudflare's entire docs via wrangler docs [search term here].
By default, if the search fails to find what you're looking for, you'll get an error like this:
✘ [ERROR] Could not find docs for: <search term goes here>. Please try again with another search term.
If you provide the --yes or -y flag, wrangler will open the docs to https://developers.cloudflare.com/workers/wrangler/commands/, even if the search fails.
Notably, this adds native support for Windows to wrangler dev --experimental-local, logging for incoming requests, and support for a bunch of newer R2
#3058 1bd50f56 Thanks @mrbbot! - chore: upgrade miniflare@3 to 3.0.0-next.13
Notably, this adds native support for Windows to wrangler dev --experimental-local, logging for incoming requests, and support for a bunch of newer R2 features.
#3058 1bd50f56 Thanks @mrbbot! - fix: disable persistence without --persist in --experimental-local
This ensures --experimental-local doesn't persist data on the file-system, unless the --persist flag is set.
Data is still always persisted between reloads.
#3055 5f48c405 Thanks @rozenmd! - fix: Teach D1 commands to read auth configuration from wrangler.toml
This PR fixes a bug in how D1 handles a user's accounts. We've updated the D1 commands to read from config (typically via wrangler.toml) before trying to run commands. This means if an account_id is defined in config, we'll use that instead of erroring out when there are multiple accounts to pick from.
Fixes #3046
### Patch Changes - #2783 `4c55baf9` Thanks @GregBrimble! - feat: Add /*.wasm?module as default module rule (alias of /*.wasm) * #2989 `86e942bb` Than
4c55baf9 Thanks @GregBrimble! - feat: Add **/*.wasm?module as default module rule (alias of **/*.wasm)86e942bb Thanks @GregBrimble! - fix: Durable Object proxying websockets over local dev registryWhen the --no-bundle flag is set, Wrangler now has support for uploading additional modules alongside the entrypoint. This will allow modules to be im
#2769 0a779904 Thanks @penalosa! - feature: Support modules with --no-bundle
When the --no-bundle flag is set, Wrangler now has support for uploading additional modules alongside the entrypoint. This will allow modules to be imported at runtime on Cloudflare's Edge. This respects Wrangler's module rules configuration, which means that only imports of non-JS modules will trigger an upload by default. For instance, the following code will now work with --no-bundle (assuming the example.wasm file exists at the correct path):
// index.js
import wasm from './example.wasm'
export default {
async fetch() {
await WebAssembly.instantiate(wasm, ...)
...
}
}
For JS modules, it's necessary to specify an additional module rule (or rules) in your wrangler.toml to configure your modules as ES modules or Common JS modules. For instance, to upload additional JavaScript files as ES modules, add the following module rule to your wrangler.toml, which tells Wrangler that all **/*.js files are ES modules.
rules = [
{ type = "ESModule", globs = ["**/*.js"]},
]
If you have Common JS modules, you'd configure Wrangler with a CommonJS rule (the following rule tells Wrangler that all .cjs files are Common JS modules):
rules = [
{ type = "CommonJS", globs = ["**/*.cjs"]},
]
In most projects, adding a single rule will be sufficient. However, for advanced usecases where you're mixing ES modules and Common JS modules, you'll need to use multiple rule definitions. For instance, the following set of rules will match all .mjs files as ES modules, all .cjs files as Common JS modules, and the nested/say-hello.js file as Common JS.
rules = [
{ type = "CommonJS", globs = ["nested/say-hello.js", "**/*.cjs"]},
{ type = "ESModule", globs = ["**/*.mjs"]}
]
If multiple rules overlap, Wrangler will log a warning about the duplicate rules, and will discard additional rules that matches a module. For example, the following rule configuration classifies dep.js as both a Common JS module and an ES module:
rules = [
{ type = "CommonJS", globs = ["dep.js"]},
{ type = "ESModule", globs = ["dep.js"]}
]
Wrangler will treat dep.js as a Common JS module, since that was the first rule that matched, and will log the following warning:
▲ [WARNING] Ignoring duplicate module: dep.js (esm)
This also adds a new configuration option to wrangler.toml: base_dir. Defaulting to the directory of your Worker's main entrypoint, this tells Wrangler where your additional modules are located, and determines the module paths against which your module rule globs are matched.
For instance, given the following directory structure:
- wrangler.toml
- src/
- index.html
- vendor/
- dependency.js
- js/
- index.js
If your wrangler.toml had main = "src/js/index.js", you would need to set base_dir = "src" in order to be able to import src/vendor/dependency.js and src/index.html from src/js/index.js.
#2957 084b2c58 Thanks @esimons! - fix: Respect querystring params when calling .fetch on a worker instantiated with unstable_dev
Previously, querystring params would be stripped, causing issues for test cases that depended on them. For example, given the following worker script:
export default {
fetch(req) {
const url = new URL(req.url);
const name = url.searchParams.get("name");
return new Response("Hello, " + name);
},
};
would fail the following test case:
const worker = await unstable_dev("script.js");
const res = await worker.fetch("http://worker?name=Walshy");
const text = await res.text();
expect(text).toBe("Hello, Walshy");
#2840 e311bbbf Thanks @mrbbot! - fix: make WRANGLER_LOG case-insensitive, warn on unexpected values, and fallback to log if invalid
Previously, levels set via the WRANGLER_LOG environment-variable were case-sensitive.
If an unexpected level was set, Wrangler would fallback to none, hiding all logs.
The fallback has now been switched to log, and lenient case-insensitive matching is used when setting the level.
eebad0d9 Thanks @kuba-orlik! - fix: allow programmatic dev workers to be stopped and started in a single session3f7a75cc Thanks @JacobMGEvans! - Fix: Generate Remote URL
Previous URL was pointing to the old cloudflare/templates repo,
updated the URL to point to templates in the workers-sdk monorepo.Support send email bindings in order to send emails from a worker. There are three types of bindings:
#2914 9af1a640 Thanks @edevil! - feat: add support for send email bindings
Support send email bindings in order to send emails from a worker. There are three types of bindings:
#2931 5f6c4c0c Thanks @Skye-31! - Fix: Pages Dev incorrectly allowing people to turn off local mode
Local mode is not currently supported in Pages Dev, and errors when people attempt to use it. Previously, wrangler hid the "toggle local mode" button when using Pages dev, but this got broken somewhere along the line.
Going forward Workers will be providing built-in modules (similar to node:...) that can be imported using the cloudflare:... prefix. This change adds
#2905 6fd06241 Thanks @edevil! - feat: support external imports from cloudflare:... prefixed modules
Going forward Workers will be providing built-in modules (similar to node:...) that can be imported using the cloudflare:... prefix. This change adds support to the Wrangler bundler to mark these imports as external.
163dccf4 Thanks @jspspike@gmail.com! - feature: add wrangler deployment view and wrangler rollback subcommandswrangler deployments view [deployment-id] will get the details of a deployment, including bindings and usage model information.
This information can be used to help debug bad deployments.
wrangler rollback [deployment-id] will rollback to a specific deployment in the runtime. This will be useful in situations like recovering from a bad
deployment quickly while resolving issues. If a deployment id is not specified wrangler will rollback to the previous deployment. This rollback only changes the code in the runtime and doesn't affect any code or configurations
in a developer's local setup.
wrangler deployments list will list the 10 most recent deployments. This command originally existed as wrangler deployments
example of view <deployment-id> output:
Deployment ID: 07d7143d-0284-427e-ba22-2d5e6e91b479
Created on: 2023-03-02T21:05:15.622446Z
Author: jspspike@gmail.com
Source: Upload from Wrangler 🤠
------------------------------------------------------------
Author ID: e5a3ca86e08fb0940d3a05691310bb42
Usage Model: bundled
Handlers: fetch
Compatibility Date: 2022-10-03
--------------------------bindings--------------------------
[[r2_buckets]]
binding = "MY_BUCKET"
bucket_name = "testr2"
[[kv_namespaces]]
id = "79300c6d17eb4180a07270f450efe53f"
binding = "yeee"
#2859 ace46939 Thanks @jbwcloudflare! - feature: add support for Queue Consumer concurrency
Consumer concurrency allows a consumer Worker processing messages from a queue to automatically scale out horizontally in order to keep up with the rate that messages are being written to a queue.
The new max_concurrency setting can be used to limit the maximum number of concurrent consumer Worker invocations.
#2838 9fa6b167 Thanks @mrbbot! - fix: display cause when local D1 migrations fail to apply
Previously, if wrangler d1 migrations apply --local failed, you'd see something like:
❌ Migration 0000_migration.sql failed with following Errors
┌──────────┐
│ Error │
├──────────┤
│ D1_ERROR │
└──────────┘
We'll now show the SQLite error that caused the failure:
❌ Migration 0000_migration.sql failed with following Errors
┌───────────────────────────────────────────────┐
│ Error │
├───────────────────────────────────────────────┤
│ Error: SqliteError: unknown database "public" │
└───────────────────────────────────────────────┘
This PR makes it possible to query D1 from an Email Worker, assuming a binding has been setup.
e33bea9b Thanks @WalshyDev! - Changed console.debug for logger.debug in Pages uploading. This will ensure the debug logs are only sent when debug logging is enabled with WRANGLER_LOG=debug.### Patch Changes - #2873 `5bcc333d` Thanks @GregBrimble! - fix: Prevent compile loop when using _worker.js and wrangler pages dev
5bcc333d Thanks @GregBrimble! - fix: Prevent compile loop when using _worker.js and wrangler pages devThis deprecates --outfile when building a Pages Plugin with --plugin.
#2839 ad4b123b Thanks @mrbbot! - fix: remove vitest from wrangler init's generated tsconfig.json types array
Previously, wrangler init generated a tsconfig.json with "types": ["@cloudflare/workers-types", "vitest"], even if Vitest tests weren't generated.
Unlike Jest, Vitest doesn't provide global APIs by default, so there's no need for ambient types.
8d462c0c Thanks @GregBrimble! - chore: Remove the --experimental-worker-bundle option from Pages Functionse3c036d7 Thanks @Cyb3r-Jak3! - feature: include .wrangler directory in gitignore template used with wrangler init#2806 8d462c0c Thanks @GregBrimble! - feat: Add --outdir as an option when running wrangler pages functions build.
This deprecates --outfile when building a Pages Plugin with --plugin.
When building functions normally, --outdir may be used to produce a human-inspectable format of the _worker.bundle that is produced.
#2806 8d462c0c Thanks @GregBrimble! - Enable bundling in Pages Functions by default.
We now enable bundling by default for a functions/ folder and for an _worker.js in Pages Functions. This allows you to use external modules such as Wasm. You can disable this behavior in Direct Upload projects by using the --no-bundle argument in wrangler pages publish and wrangler pages dev.
#2836 42fb97e5 Thanks @GregBrimble! - fix: preserve the entrypoint filename when running wrangler publish --outdir <dir>.
Previously, this entrypoint filename would sometimes be overwritten with some internal filenames. It should now be based off of the entrypoint you provide for your Worker.
#2828 891ddf19 Thanks @GregBrimble! - fix: Bring pages dev logging in line with dev proper's
wrangler pages dev now defaults to logging at the log level (rather than the previous warn level), and the pages prefix is removed.
#2855 226e63fa Thanks @GregBrimble! - fix: --experimental-local with wrangler pages dev
We previously had a bug which logged an error (local worker: TypeError: generateASSETSBinding2 is not a function). This has now been fixed.
Notably, this brings the following improvements to wrangler dev --experimental-local:
#2810 62784131 Thanks @mrbbot! - chore: upgrade @miniflare/tre to 3.0.0-next.12, incorporating changes from 3.0.0-next.11
Notably, this brings the following improvements to wrangler dev --experimental-local:
better-sqlite3@8, allowing installation on Node 194756d6a1 Thanks @alankemp! - Add new [unsafe.metadata] section to wrangler.toml allowing arbitary data to be added to the metadata section of the upload#2539 3725086c Thanks @GregBrimble! - feat: Add support for the nodejs_compat Compatibility Flag when bundling a Worker with Wrangler
This new Compatibility Flag is incompatible with the legacy --node-compat CLI argument and node_compat configuration option. If you want to use the new runtime Node.js compatibility features, please remove the --node-compat argument from your CLI command or your config file.
### Patch Changes - #2795 `ec3e181e` Thanks @penalosa! - fix: Adds a duplex: "half" property to R2 fetch requests with stream bodies in order to be co
ec3e181e Thanks @penalosa! - fix: Adds a duplex: "half" property to R2 fetch requests with stream bodies in order to be compatible with undici v5.204ca8c0b0 Thanks @GregBrimble! - fix: Support overriding the next URL in subsequent executions with next("/new-path") from within a Pages PluginThis will look something like the following, where a request to /users/123 will appear as that in the browser, but will internally go to /users/[id].h
a9adfbe7 Thanks @penalosa! - Previously, wrangler dev would not work if the root of your zone wasn't behind Cloudflare. This behaviour has changed so that now only the route which your Worker is exposed on has to be behind Cloudflare.#2708 b3346cfb Thanks @Skye-31! - Feat: Pages now supports Proxying (200 status) redirects in it's _redirects file
This will look something like the following, where a request to /users/123 will appear as that in the browser, but will internally go to /users/[id].html.
/users/:id /users/[id] 200
#2766 7912e63a Thanks @mrbbot! - fix: correctly detect service-worker format when using typeof module
Wrangler automatically detects whether your code is a modules or service-worker format Worker based on the presence of a default export. This check currently works by building your entrypoint with esbuild and looking at the output metafile.
Previously, we were passing format: "esm" to esbuild when performing this check, which enables format conversion. This may introduce export default into the built code, even if it wasn't there to start with, resulting in incorrect format detections.
This change removes format: "esm" which disables format conversion when bundling is disabled. See https://esbuild.github.io/api/#format for more details.
#2780 80f1187a Thanks @GregBrimble! - fix: Ensure we don't mangle internal constructor names in the wrangler bundle when building with esbuild
Undici changed how they referenced FormData, which meant that when used in our bundle process, we were failing to upload multipart/form-data bodies. This affected wrangler pages publish and wrangler publish.
#2720 de0cb57a Thanks @JacobMGEvans! - Fix: Upgraded to ES2022 for improved compatibility
Upgraded worker code target version from ES2020 to ES2022 for better compatibility and unblocking of a workaround related to issue #2029. The worker runtime now uses the same V8 version as recent Chrome and is 99% ES2016+ compliant. The only thing we don't support on the Workers runtime, the remaining 1%, is the ES2022 RegEx feature as seen in the compat table for the latest Chrome version.
Compatibility table: https://kangax.github.io/compat-table/es2016plus/
4ede044e Thanks @mrbbot! - chore: upgrade miniflare to 2.12.1 and @miniflare/tre to 3.0.0-next.10Functionality implemented first as an api, which is used in the cli standard api commands
#2567 02ea098e Thanks @matthewdavidrodgers! - Add mtls-certificate commands and binding support
Functionality implemented first as an api, which is used in the cli standard api commands
Note that this adds a new OAuth scope, so OAuth users will need to log out and log back in to use the new 'mtls-certificate' commands However, publishing with mtls-certifcate bindings (bindings of type 'mtls_certificate') will work without the scope.
c5943c9f Thanks @mrbbot! - Upgrade miniflare to 2.12.0, including support for R2 multipart upload bindings, the nodejs_compat compatibility flag, D1 fixes and more!#2579 bf558bdc Thanks @JacobMGEvans! - Added additional fields to the output of wrangler deployments command. The additional fields are from the new value in the response annotations which includes workers/triggered_by and rollback_from
Example:
Deployment ID: Galaxy-Class
Created on: 2021-01-04T00:00:00.000000Z
Trigger: Upload from Wrangler 🤠
Rollback from: MOCK-DEPLOYMENT-ID-2222
#2624 882bf592 Thanks @CarmenPopoviciu! - Add wasm support in wrangler pages publish
Currently it is not possible to import wasm modules in either Pages
Functions or Pages Advanced Mode projects.
This commit caries out work to address the aforementioned issue by
enabling wasm module imports in wrangler pages publish. As a result,
Pages users can now import their wasm modules withing their Functions
or _worker.js files, and wrangler pages publish will correctly
bundle everything and serve these "external" modules.
68a2a19e Thanks @mrbbot! - Fix internal middleware system to allow D1 databases and --test-scheduled to be used together58ac8a78 Thanks @dario-piotrowicz! - fix: make sure that the pages publish --no-bundle flag is correctly recognized4bc78470 Thanks @rozenmd! - fix: don't throw an error when omitting preview_database_id, warn instead2b1177ad Thanks @CarmenPopoviciu! - You can now import Wasm modules in Pages Functions and Pages Functions Advanced Mode (_worker.js).
This change specifically enables wasm module imports in wrangler pages functions build.
As a result, Pages users can now import their wasm modules within their Functions or
_worker.js files, and wrangler pages functions build will correctly bundle everything
and output the expected result file.### Patch Changes - #2652 `2efd4537` Thanks @mrkldshv! - fix: change jest to vitest types in generated TypeScript config * #2657 `8d21b2ea` Thanks @ro
This can be used to build isomorphic libraries that have different implementations depending on the JavaScript runtime they're running in. When bundli
#2629 151733e5 Thanks @mrbbot! - Prefer the workerd exports condition when bundling.
This can be used to build isomorphic libraries that have different implementations depending on the JavaScript runtime they're running in.
When bundling, Wrangler will try to load the workerd key.
This is the standard key for the Cloudflare Workers runtime.
Learn more about the conditional exports field here.
89d78c0a Thanks @penalosa! - Wrangler now supports an --experimental-json-config flag which will read your configuration from a wrangler.json file, rather than wrangler.toml. The format of this file is exactly the same as the wrangler.toml configuration file, except that the syntax is JSONC (JSON with comments) rather than TOML. This is experimental, and is not recommended for production use.04d8a312 Thanks @dario-piotrowicz! - fix d1 directory not being created when running the wrangler d1 execute command with the --yes/-y flag70daffeb Thanks @dario-piotrowicz! - fix: Add support for D1 databases when bundling an _worker.js on wrangler pages publish#2597 416babf0 Thanks @petebacondarwin! - fix: do not crash in wrangler dev when passing a request object to fetch
This reverts and fixes the changes in https://github.com/cloudflare/workers-sdk/pull/1769 which does not support creating requests from requests whose bodies have already been consumed.
Fixes #2562
#2622 9778b33e Thanks @rozenmd! - fix: implement d1 list --json with clean output for piping into other commands
Before:
rozenmd@cflaptop test % npx wrangler d1 list
--------------------
🚧 D1 is currently in open alpha and is not recommended for production data and traffic
🚧 Please report any bugs to https://github.com/cloudflare/workers-sdk/issues/new/choose
🚧 To request features, visit https://community.cloudflare.com/c/developers/d1
🚧 To give feedback, visit https://discord.gg/cloudflaredev
--------------------
┌──────────────────────────────┬─────────────────┐
│ uuid │ name │
├──────────────────────────────┼─────────────────┤
│ xxxxxx-xxxx-xxxx-xxxx-xxxxxx │ test │
├──────────────────────────────┼─────────────────┤
│ xxxxxx-xxxx-xxxx-xxxx-xxxxxx │ test2 │
├──────────────────────────────┼─────────────────┤
│ xxxxxx-xxxx-xxxx-xxxx-xxxxxx │ test3 │
└──────────────────────────────┴─────────────────┘
After:
rozenmd@cflaptop test % npx wrangler d1 list --json
[
{
"uuid": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
"name": "test"
},
{
"uuid": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
"name": "test2"
},
{
"uuid": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
"name": "test3"
},
]
6b3fe5ef Thanks @thibmeu! - Fix wrangler publish --dry-run to not require authentication when using Queues#2627 6f0f2ba6 Thanks @rozenmd! - fix: implement d1 execute --json with clean output for piping into other commands
Before:
rozenmd@cflaptop test1 % npx wrangler d1 execute test --command="select * from customers"
▲ [WARNING] Processing wrangler.toml configuration:
- D1 Bindings are currently in alpha to allow the API to evolve before general availability.
Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
Note: Run this command with the environment variable NO_D1_WARNING=true to hide this message
For example: `export NO_D1_WARNING=true && wrangler <YOUR COMMAND HERE>`
--------------------
🚧 D1 is currently in open alpha and is not recommended for production data and traffic
🚧 Please report any bugs to https://github.com/cloudflare/workers-sdk/issues/new/choose
🚧 To request features, visit https://community.cloudflare.com/c/developers/d1
🚧 To give feedback, visit https://discord.gg/cloudflaredev
--------------------
🌀 Mapping SQL input into an array of statements
🌀 Parsing 1 statements
🌀 Executing on test (xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx):
🚣 Executed 1 command in 11.846710999961942ms
┌────────────┬─────────────────────┬───────────────────┐
│ CustomerID │ CompanyName │ ContactName │
├────────────┼─────────────────────┼───────────────────┤
│ 1 │ Alfreds Futterkiste │ Maria Anders │
├────────────┼─────────────────────┼───────────────────┤
│ 4 │ Around the Horn │ Thomas Hardy │
├────────────┼─────────────────────┼───────────────────┤
│ 11 │ Bs Beverages │ Victoria Ashworth │
├────────────┼─────────────────────┼───────────────────┤
│ 13 │ Bs Beverages │ Random Name │
└────────────┴─────────────────────┴───────────────────┘
After:
rozenmd@cflaptop test1 % npx wrangler d1 execute test --command="select * from customers" --json
[
{
"results": [
{
"CustomerID": 1,
"CompanyName": "Alfreds Futterkiste",
"ContactName": "Maria Anders"
},
{
"CustomerID": 4,
"CompanyName": "Around the Horn",
"ContactName": "Thomas Hardy"
},
{
"CustomerID": 11,
"CompanyName": "Bs Beverages",
"ContactName": "Victoria Ashworth"
},
{
"CustomerID": 13,
"CompanyName": "Bs Beverages",
"ContactName": "Random Name"
}
],
"success": true,
"meta": {
"duration": 1.662519000004977,
"last_row_id": null,
"changes": null,
"served_by": "primary-xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.db3",
"internal_stats": null
}
}
]
This PR makes it possible to access D1 from Durable Objects.
#2501 a0e5a491 Thanks @geelen! - fix: make it possible to query d1 databases from durable objects
This PR makes it possible to access D1 from Durable Objects.
To be able to query D1 from your Durable Object, you'll need to install the latest version of wrangler, and redeploy your Worker.
For a D1 binding like:
[[d1_databases]]
binding = "DB" # i.e. available in your Worker on env.DB
database_name = "my-database-name"
database_id = "UUID-GOES-HERE"
preview_database_id = "UUID-GOES-HERE"
You'll be able to access your D1 database via env.DB in your Durable Object.
ef110923 Thanks @penalosa! - Support queue and trace events in module middleware. This means that queue and trace events should work properly with the --test-scheduled flag#2554 fbeaf609 Thanks @CarmenPopoviciu! - feat: Add support for wasm module imports in wrangler pages dev
Currently it is not possible to import wasm modules in either Pages
Functions or Pages Advanced Mode projects.
This commit caries out work to address the aforementioned issue by
enabling wasm module imports in wrangler pages dev. As a result,
Pages users can now import their wasm modules withing their Functions
or _worker.js files, and wrangler pages dev will correctly bundle
everything and serve these "external" modules.
import hello from "./hello.wasm"
export async function onRequest() {
const module = await WebAssembly.instantiate(hello);
return new Response(module.exports.hello);
}
#2563 5ba39569 Thanks @CarmenPopoviciu! - fix: Copy module imports related files to outdir
When we bundle a Worker esbuild takes care of writing the
results to the output directory. However, if the Worker contains
any external imports, such as text/wasm/binary module imports,
that cannot be inlined into the same bundle file, bundleWorker
will not copy these files to the output directory. This doesn't
affect wrangler publish per se, because of how the Worker
upload FormData is created. It does however create some
inconsistencies when running wrangler publish --outdir or
wrangler publish --outdir --dry-run, in that, outdir will
not contain those external import files.
This commit addresses this issue by making sure the aforementioned
files do get copied over to outdir together with esbuild's
resulting bundle files.
Previously, if you provided a _worker.js file, then Pages would simply check the file for disallowed imports and then deploy the file as-is.
#2404 3f824347 Thanks @petebacondarwin! - feat: support bundling the raw Pages _worker.js before deploying
Previously, if you provided a _worker.js file, then Pages would simply check the
file for disallowed imports and then deploy the file as-is.
Not bundling the _worker.js file means that it cannot containing imports to other
JS files, but also prevents Wrangler from adding shims such as the one for the D1 alpha
release.
This change adds the ability to tell Wrangler to pass the _worker.js through the
normal Wrangler bundling process before deploying by setting the --bundle
command line argument to wrangler pages dev and wrangler pages publish.
This is in keeping with the same flag for wrangler publish.
Currently bundling is opt-in, flag defaults to false if not provided.
b44e1a75 Thanks @GregBrimble! - chore: Rename --bundle to --no-bundle in Pages commands to make similar to Workers#2551 bfffe595 Thanks @rozenmd! - fix: wrangler init --from-dash incorrectly expects index.ts while writing index.js
This PR fixes a bug where Wrangler would write a wrangler.toml expecting an index.ts file, while writing an index.js file.
#2529 2270507c Thanks @CarmenPopoviciu! - Remove "experimental _routes.json" warnings
_routes.json is no longer considered an experimental feature, so let's
remove all warnings we have in place for that.
#2548 4db768fa Thanks @rozenmd! - fix: path should be optional for wrangler d1 backup download
This PR fixes a bug that forces folks to provide a --output flag to wrangler d1 backup download.
#2528 18208091 Thanks @caass! - Add some guidance when folks encounter a 10021 error.
Error code 10021 can occur when your worker doesn't pass startup validation. This error message will make it a little easier to reason about what happened and what to do next.
Closes #2519
6a67efe9 Thanks @dario-piotrowicz! - allow fetch() calls locally to accept URL ObjectsA subtle difference when removing object-spreading of experimental unstable_dev() options caused wrangler pages dev interactivity to stop working. Thi
#2523 a5e9958c Thanks @jahands! - fix: unstable_dev() experimental options incorrectly applying defaults
A subtle difference when removing object-spreading of experimental unstable_dev() options caused wrangler pages dev interactivity to stop working. This switches back to object-spreading the passed in options on top of the defaults, fixing the issue.
When applying D1 migrations to a deployed database, it is important that we are logged in and that we have the database ID from the wrangler.toml. Thi
#2465 e1c2f5b9 Thanks @JacobMGEvans! - After this PR, wrangler init --yes will generate a test for your new Worker project, using Vitest with TypeScript.
When using wrangler init, and choosing to create a Typescript project, you will now be asked if Wrangler should write tests for you, using Vitest.
This resolves issue #2436.
71691421 Thanks @markjmiller! - Remove the experimental binding warning from Dispatch Namespace since it is GA.c2b2dfb8 Thanks @rozenmd! - fix: resolve unstable_dev flakiness in tests by awaiting the dev registry#2439 616f8739 Thanks @petebacondarwin! - fix(wrangler): do not login or read wrangler.toml when applying D1 migrations in local mode.
When applying D1 migrations to a deployed database, it is important that we are logged in
and that we have the database ID from the wrangler.toml.
This is not needed for --local mode where we are just writing to a local SQLite file.
#1869 917b07b0 Thanks @petebacondarwin! - feat: enable Wrangler to target the staging API by setting WRANGLER_API_ENVIRONMENT=staging
If you are developing Wrangler, or an internal Cloudflare feature, and during testing,
need Wrangler to target the staging API rather than production, it is now possible by
setting the WRANGLER_API_ENVIRONMENT environment variable to staging.
This will update all the necessary OAuth and API URLs, update the OAuth client ID, and also (if necessary) acquire an Access token for to get through the firewall to the staging URLs.
32686e42 Thanks @mrbbot! - Fix ReferenceError when using wrangler dev --experimental-local in Node 16#2485 4c0e2309 Thanks @GregBrimble! - fix: Pages Plugin routing when mounted at the root of a project
Previously, there was a bug which meant that Plugins mounted at the root of a Pages project were not correctly matching incoming requests. This change fixes that bug so Plugins mounted at the root should now correctly work.
#2479 7b479b91 Thanks @rozenmd! - fix: bump d1js
This PR bumps d1js, adding the following functionality to the d1 alpha shim:
7785591c Thanks @rozenmd! - fix: improve wrangler init --from-dash help text and error handling#2391 19525a4b Thanks @mrbbot! - Always log when delegating to local wrangler install.
When a global wrangler command is executed in a package directory with wrangler installed locally, the command is redirected to the local wrangler install.
We now always log a message when this happens, so you know what's going on.
97282459 Thanks @rozenmd! - BREAKING CHANGE: move experimental options under the experimental object for unstable_dev#2495 e93063e9 Thanks @petebacondarwin! - fix(d1): ensure that migrations support compound statements
This fix updates the SQL statement splitting so that it does not split in the middle of compound statements.
Previously we were using a third party splitting library, but this needed fixing and was actually unnecessary for our purposes.
So a new splitter has been implemented and the library dependency removed.
Also the error handling in d1 migrations apply has been improved to handle a wider range of error types.
Fixes #2463
08a0b22e Thanks @mrbbot! - Cleanly exit wrangler dev --experimental-local when pressing x/q/CTRL-C#2374 ecba1ede Thanks @rozenmd! - fix: make --from-dash error output clearer
This PR makes it clearer what --from-dash wants from you.
closes #2373 closes #2375
32686e42 Thanks @mrbbot! - Respect FORCE_COLOR=0 environment variable to disable colored output when using wrangler dev --local#2455 d9c1d273 Thanks @rozenmd! - BREAKING CHANGE: refactor unstable_dev to use an experimental object, instead of a second options object
Before, if you wanted to disable the experimental warning, you would run:
worker = await unstable_dev(
"src/index.js",
{},
{ disableExperimentalWarning: true }
);
After this change, you'll need to do this instead:
worker = await unstable_dev("src/index.js", {
experimental: { disableExperimentalWarning: true },
});
### Patch Changes - #2355 `df6fea02` Thanks @rozenmd! - fix: don't ask for preview_database_id in --local * #2349 `8173bcca` Thanks @jspspike! - Initi
Previously, we introduced a bug where we were incorrectly requiring @miniflare/tre, even when not using the workerd/--experimental-local mode.
#2339 f6821189 Thanks @GregBrimble! - fix: wrangler dev --local now correctly lazy-imports @miniflare/tre
Previously, we introduced a bug where we were incorrectly requiring @miniflare/tre, even when not using the workerd/--experimental-local mode.
Add @miniflare/tre environment polyfill to @cloudflare/pages-shared.
#2268 3be1c2cf Thanks @GregBrimble! - feat: Add support for --experimental-local to wrangler pages dev which will use the workerd runtime.
Add @miniflare/tre environment polyfill to @cloudflare/pages-shared.
#2163 d73a34be Thanks @jimhawkridge! - feat: Add support for Analytics Engine bindings.
For example:
analytics_engine_datasets = [
{ binding = "ANALYTICS", dataset = "my_dataset" }
]
#2177 e98613f8 Thanks @caass! - Trigger login flow if a user runs wrangler dev while logged out
Previously, we would just error if a user logged out and then ran wrangler dev.
Now, we kick them to the OAuth flow and suggest running wrangler dev --local if
the login fails.
Closes #2147
#2298 bb5e4f91 Thanks @rozenmd! - fix: d1 not using the preview database when using wrangler dev
After this fix, wrangler will correctly connect to the preview database, rather than the prod database when using wrangler dev
#2176 d48ee112 Thanks @caass! - Use the user's preferred default branch name if set in .gitconfig.
Previously, we would initialize new workers with main as the name of the default branch.
Now, we see if the user has a custom setting in .gitconfig for init.defaultBranch, and use
that if it exists.
Closes #2112
As of this change, wrangler's d1 migrations commands now accept local and persist-to as flags, so migrations can run against the local d1 db.
b24c2b2d Thanks @dalbitresb12! - feat: Allow pages dev to proxy websocket requests7da8f0e6 Thanks @Skye-31! - Fix: check response status of d1 backup download command before writing contents to file#2260 c2940160 Thanks @rozenmd! - fix: make it possible to use a local db for d1 migrations
As of this change, wrangler's d1 migrations commands now accept local and persist-to as flags, so migrations can run against the local d1 db.
60d31c01 Thanks @GregBrimble! - fix: Fix --port=0 option to report the actually used port.### Patch Changes - #2265 `42d88e3f` Thanks @WalshyDev! - Fix D1 bindings in wrangler pages dev
42d88e3f Thanks @WalshyDev! - Fix D1 bindings in wrangler pages devPrior to this change wrangler would only ever use local mode when testing d1.
e41c7e41 Thanks @mrbbot! - Enable pretty source-mapped error pages when using --experimental-local5bd04296 Thanks @OilyLime! - Add link to Queues tab in dashboard when unauthorized to use Queues### Patch Changes - #2232 `5241925a` Thanks @mrbbot! - Fix wrangler types generation for service-worker type Workers`
### Patch Changes - #2229 `8eb53b1a` Thanks @mrbbot! - Unhide --live-reload option for local mode development * #2209 `d0f237d9` Thanks @JacobMGEvans!
Publishing Pages projects containing a functions directory incorrectly did not upload the filepath-routing config so that the user can view it in Dash
#2193 0047ad30 Thanks @JacobMGEvans! - Local Mode Console Support
Added support for detailed console.log capability when using --experimental-local
resolves #2122
add4278a Thanks @mrbbot! - Add a --experimental-local-remote-kv flag to enable reading/writing from/to real KV namespaces.
Note this flag requires --experimental-local to be enabled.#2204 c725ce01 Thanks @jahands! - fix: Upload filepath-routing configuration in wrangler pages publish
Publishing Pages projects containing a functions directory incorrectly did not upload the filepath-routing config so that the user can view it in Dash. This fixes that, making the generated routes viewable under Routing configuration in the Functions tab of a deployment.
### Patch Changes - #2197 `a3533024` Thanks @geelen! - fix: truncate lines longer than 70 chars when executing d1 sql
### Patch Changes - #2194 `3dccedf1` Thanks @rozenmd! - fix: make it possible to use d1 in scheduled and queue workers
### Minor Changes - #2077 `c9b564dc` Thanks @jrf0110! - Adds tailing for Pages Functions ### Patch Changes - #2178 `d165b741` Thanks @JacobMGEvans! -
Nothing published for this version
### Patch Changes - #2182 `7d8d53a7` Thanks @geelen! - Wrangler D1 now supports the alpha release of migrations. * #2138 `2be9d642` Thanks @mrbbot! -
### Patch Changes - #2172 `47a142af` Thanks @KianNH! - Validate object size for wrangler r2 put * #2161 `dff756f3` Thanks @jbw1991! - Check for the co
### Patch Changes - #2067 `758419ed` Thanks @Skye-31! - fix: Accurately determine when using imports in \_worker.js for Advanced Mode Pages Functions
Better and faster handling when importing big SQL files using execute --file
511943e9 Thanks @celso! - fix: D1 execute and backup commands improvements
#2130 68f4fa6f Thanks @matthewdavidrodgers! - feature: Add warnings around bundle sizes for large scripts
Prints a warning for scripts > 1MB compressed, encouraging smaller script sizes. This warning can be silenced by setting the NO_SCRIPT_SIZE_WARNING env variable
If a publish fails with either a script size error or a validator error on script startup (CPU or memory), we print out the largest 5 dependencies in your bundle. This is accomplished by using the esbuild generated metafile.
49b6a484 Thanks @jbw1991! - Adds support for Cloudflare Queues. Adds new CLI commands to configure Queues. Queue producers and consumers can be defined in wrangler.toml.5640fe88 Thanks @penalosa! - Enable support for wrangler dev on Workers behind Cloudflare Access, utilising cloudflared. If you don't have cloudflared installed, Wrangler will prompt you to install it. If you do, then the first time you start developing using wrangler dev your default browser will open with a Cloudflare Access prompt.#2127 0e561e83 Thanks @JacobMGEvans! - Fix: Missing Worker name using --from-dash
Added the --from-dash name as a fallback when no name is provided in the wrangler init command.
Additionally added a checks to the std.out to ensure that the name is provided.
resolves #1853
1987a79d Thanks @mrbbot! - If --env <env> is specified, we'll now check .env.<env>/.dev.vars.<env> first.
If they don't exist, we'll fallback to .env/.dev.vars.06aa6121 Thanks @mrbbot! - Fixed importing installed npm packages with the same name as Node built-in
modules if node_compat is disabled.#2124 02ca556c Thanks @JacobMGEvans! - Computing the name from binding response
Now the vars will be computed, example:
[var.binding.name]: var.binding.text
this will resolve the issue that was occurring with
generating a TOML with incorrect fields for the vars key/value pair.
resolves #2048
If the root directory of a project was the same as the build output directory, we were previously uploading the functions/ directory as static assets.
#2103 f1fd62a1 Thanks @GregBrimble! - fix: Don't upload functions/ directory as part of wrangler pages publish
If the root directory of a project was the same as the build output directory, we were previously uploading the functions/ directory as static assets. This PR now ensures that the functions/ files are only used to create Pages Functions and are no longer uploaded as static assets.
Additionally, we also now do upload _worker.js, _headers, _redirects and _routes.json if they aren't immediate children of the build output directory. Previously, we'd ignore all files with this name regardless of location. For example, if you have a public/blog/how-to-use-pages/_headers file (where public is your build output directory), we will now upload the _headers file as a static asset.
#2111 ab52f771 Thanks @GregBrimble! - feat: Add a passThroughOnException() handler in Pages Functions
This passThroughOnException() handler is not as good as the built-in for Workers. We're just adding it now as a stop-gap until we can do the behind-the-scenes plumbing required to make the built-in function work properly.
We wrap your Pages Functions code in a try/catch and on failure, if you call passThroughOnException() we defer to the static assets of your project.
For example:
export const onRequest = ({ passThroughOnException }) => {
passThroughOnException();
x; // Would ordinarily throw an error, but instead, static assets are served.
};
Custom module rules generate declare modules based on the module type (Text, Data or CompiledWasm). Module Example Outputs:
#2074 b08ab1e5 Thanks @JacobMGEvans! - The type command aggregates bindings and custom module rules from config, then generates a DTS file for both service workers' declare global { ... } or module workers' interface Env { ... }
Custom module rules generate declare modules based on the module type (Text, Data or CompiledWasm).
Module Example Outputs:
CompiledWasm
declare module "**/*.wasm" {
const value: WebAssembly.Module;
export default value;
}
Data
declare module "**/*.webp" {
const value: ArrayBuffer;
export default value;
}
Text
declare module "**/*.text" {
const value: string;
export default value;
}
resolves #2034 resolves #2033
#2065 14c44588 Thanks @CarmenPopoviciu! - fix(pages): wrangler pages dev matches routing rules in _routes.json too loosely
Currently, the logic by which we transform routing rules in _routes.json to
regular expressions, so we can perform pathname matching & routing when we
run wrangler pages dev, is too permissive, and leads to serving incorrect
assets for certain url paths.
For example, a routing rule such as /foo will incorrectly match pathname
/bar/foo. Similarly, pathname /foo will be incorrectly matched by the
/ routing rule.
This commit fixes our routing rule to pathname matching logic and brings
wrangler pages dev on par with routing in deployed Pages projects.
#2098 2a81caee Thanks @threepointone! - feat: delete site/assets namespace when a worker is deleted
This patch deletes any site/asset kv namespaces associated with a worker when wrangler delete is used. It finds the namespace associated with a worker by using the names it would have otherwise used, and deletes it. It also does the same for the preview namespace that's used with wrangler dev.
#2091 9491d86f Thanks @JacobMGEvans! - Wrangler deployments command
Added support for the deployments command, which allows you to list the last ten deployments for a given script.
The information will include:
resolves #2089
Like wrangler dev proper, wrangler pages dev now defaults to using today's compatibility date. It can be overriden with --compatibility-date=YYYY-MM-D
#2026 7d987ee2 Thanks @GregBrimble! - fix: Default to today's compatibility date in wrangler pages dev
Like wrangler dev proper, wrangler pages dev now defaults to using today's compatibility date.
It can be overriden with --compatibility-date=YYYY-MM-DD.
https://developers.cloudflare.com/workers/platform/compatibility-dates/
76a66fc2 Thanks @penalosa! - Warn when opening a tail on workers for which a restart could be disruptive (i.e. Workers which use Durable Objects in conjunction with WebSockets)#2045 c2d3286f Thanks @threepointone! - feat: implement a basic wrangler delete
This PR adds a simple (but useful!) implementation for wrangler delete. Of note, it'll delete a given service, including all it's bindings. It uses the same api as the dashboard.
Previously, when trying to publish a worker to a route that was in use by another worker, there would be a really unhelpful message about a failed API
#2023 d6660ce3 Thanks @caass! - Display a more helpful error when trying to publish to a route in use by another worker.
Previously, when trying to publish a worker to a route that was in use by another worker, there would be a really unhelpful message about a failed API call. Now, there's a much nicer message that tells you what worker is running on that route, and gives you a link to the workers overview page so you can unassign it if you want.
⛅️ wrangler 2.1.11
--------------------
Total Upload: 0.20 KiB / gzip: 0.17 KiB
✘ [ERROR] Can't publish a worker to routes that are assigned to another worker.
"test-custom-routes-redeploy" is already assigned to route
test-custom-worker.swag.lgbt
Unassign other workers from the routes you want to publish to, and then try again.
Visit
https://dash.cloudflare.com/<account_id>/workers/overview
to unassign a worker from a route.
Closes #1849
#2013 c63ca0a5 Thanks @rozenmd! - fix: make d1 help print if a command is incomplete
Prior to this change, d1's commands would return silently if wrangler wasn't supplied enough arguments to run the command.
This change resolves this issue, and ensures help is always printed if the command couldn't run.
#2016 932fecc0 Thanks @caass! - Offer to create a workers.dev subdomain if a user needs one
Previously, when a user wanted to publish a worker to https://workers.dev by setting workers_dev = true in their wrangler.toml,
but their account didn't have a subdomain registered, we would error out.
Now, we offer to create one for them. It's not implemented for wrangler dev, which also expects you to have registered a
workers.dev subdomain, but we now error correctly and tell them what the problem is.
3ed06b40 Thanks @GregBrimble! - chore: Bump miniflare@2.10.0#2024 4ad48e4d Thanks @rozenmd! - fix: make it possible for values in vars and defines to have colons (:)
Prior to this change, passing --define someKey:https://some-value.com would result in an incomplete value being passed to the Worker.
This change correctly handles colons for var and define in wrangler dev and wrangler publish.
#2032 f33805d2 Thanks @caass! - Catch unsupported terminal errors and provide a nicer error message.
Wrangler depends on terminals supporting raw mode. Previously, attempting to run wrangler from a terminal that didn't support raw mode would result in an Ink error, which was both an exposure of an internal implementation detail to the user and also not actionable:
ERROR Raw mode is not supported on the current process.stdin, which Ink uses
as input stream by default.
Read about how to prevent this error on
https://github.com/vadimdemedes/ink/#israwmodesupported
Now, we provide a much nicer error, which provides an easy next step for th user:
ERROR: This terminal doesn't support raw mode.
Wrangler uses raw mode to read user input and write output to the terminal, and won't function correctly without it.
Try running your previous command in a terminal that supports raw mode, such as Command Prompt or Powershell.
Closes #1992
Previously, wrangler generate was a thin wrapper around `create-cloudflare`. Now, we've moved over the logic from that package directly into wrangler.
#1957 b579c2b5 Thanks @caass! - Remove dependency on create-cloudflare.
Previously, wrangler generate was a thin wrapper around create-cloudflare. Now, we've moved over the logic from that package directly into wrangler.
ea54623c Thanks @CarmenPopoviciu! - wrangler pages publish should prioritize _worker.js over /functions if both exist#1950 daf73fbe Thanks @CarmenPopoviciu! - wrangler pages dev should prioritize _worker.js
When using a _worker.js file, the entire /functions directory should be ignored – this includes its routing and middleware characteristics. Currently wrangler pages dev does the reverse, by prioritizing
/functions over _worker.js. These changes fix the current behaviour.
c1722170 Thanks @GregBrimble! - fix: Allow unsetting of automatically generated Link headers using _headers and the ! Link operator#1928 c1722170 Thanks @GregBrimble! - fix: Only generate Link headers from simple <link> elements.
Specifically, only those with the rel, href and possibly as attributes. Any element with additional attributes will not be used to generate headers.
a96f2585 Thanks @GregBrimble! - chore: Bump @cloudflare/pages-shared@0.0.7 and use TS directly#1965 9709d3a3 Thanks @JacobMGEvans! - chore: remove hidden on --from-dash
The --from-dash can now be used with the dashboard features to support moving Worker developmment to a local machine.
resolves #1783
#1978 6006ae50 Thanks @JacobMGEvans! - chore: Undici 5.11.0 multipart/form-data support
The 5.11.0 version of Undici now supports multipart/form-data previously needed a ponyfill
we can now handle the multipart/form-data without any custom code.
resolves #1977
While in beta, you cannot use D1 bindings without bundling your worker as these are added in through a facade which gets bypassed when using the no-bu
#1955 b6dd07a1 Thanks @cameron-robey! - chore: error if d1 bindings used with no-bundle
While in beta, you cannot use D1 bindings without bundling your worker as these are added in through a facade which gets bypassed when using the no-bundle option.
1f50578e Thanks @JacobMGEvans! - chore: Emoji space in help description
Added a space between the Emoji and description for the secret:bulk command.#1967 02261f27 Thanks @rozenmd! - feat: implement remote mode for unstable_dev
With this change, unstable_dev can now perform end-to-end (e2e) tests against your workers as you dev.
Note that to use this feature in CI, you'll need to configure CLOUDFLARE_API_TOKEN as an environment variable in your CI, and potentially add CLOUDFLARE_ACCOUNT_ID as an environment variable in your CI, or account_id in your wrangler.toml.
Usage:
await unstable_dev("src/index.ts", {
local: false,
});
Just like in the typescript templates, and the javascript template for scheduled workers, we include env and ctx as parameters to the fetch export. Th
#1937 905fce4f Thanks @JacobMGEvans! - fix: fails to publish due to empty migrations
After this change, wrangler init --from-dash will not attempt to add durable object migrations to wrangler.toml for Workers that don't have durable objects.
fixes #1854
#1943 58a430f2 Thanks @cameron-robey! - chore: add env and ctx params to fetch in javascript example template
Just like in the typescript templates, and the javascript template for scheduled workers, we include env and ctx as parameters to the fetch export. This makes it clearer where environment variables live.
#1939 5854cb69 Thanks @rozenmd! - fix: respect variable binding type when printing
After this change, when printing the bindings it has access to, wrangler will correctly only add quotes around string variables, and serialize objects via JSON.stringify (rather than printing "[object Object]").
#1930 56798155 Thanks @rozenmd! - fix: use node http instead of faye-websocket in proxy server
We change how websockets are handled in the proxy server, fixing multiple issues of websocket behaviour, particularly to do with headers.
In particular this fixes:
### Patch Changes - #1894 `ed646cf9` Thanks @mrbbot! - Add experimental support for using the open-source Workers runtime `workerd` in wrangler dev. U
when using unstable_dev(), I think we want to expose the port/address that the server has started on. The usecase is when trying to connect to the ser
6ff5a030 Thanks @Skye-31! - Chore: correctly log all listening ports on remote mode (closes #1652)#1913 9f7cc5a0 Thanks @threepointone! - feat: expose port and address on (Unstable)DevWorker
when using unstable_dev(), I think we want to expose the port/address that the server has started on. The usecase is when trying to connect to the server without calling .fetch() (example: when making a websocket connection).
#1911 16c28502 Thanks @rozenmd! - fix: put config cache log behind logger.debug
Prior to this change, wrangler would print Retrieving cached values for... after almost every single command.
After this change, you'll only see this message if you add WRANGLER_LOG=debug before your command.
Closes #1808
By default, wrangler.toml is the source of truth for your environment configuration, like a terraform file.
#1895 1b53bf9d Thanks @rozenmd! - fix: rename keep_bindings to keep_vars, and make it opt-in, to keep wrangler.toml compatible with being used for Infrastructure as Code
By default, wrangler.toml is the source of truth for your environment configuration, like a terraform file.
If you change your settings (particularly your vars) in the dashboard, wrangler will override them. If you want to disable this behavior, set this field to true.
Between wrangler 2.0.28 and 2.1.5, by default wrangler would not delete your vars by default, breaking expected wrangler.toml behaviour.
98f756c7 Thanks @penalosa! - fix: Correctly place the .wrangler/state local state directory in the same directory as wrangler.toml by default#1886 8b647175 Thanks @JacobMGEvans! - fix: potential missing compatibility_date in wrangler.toml when running wrangler init --from-dash
Fixed a bug where compatibility_date wasn't being added to wrangler.toml when initializing a worker via wrangler init --from-dash
fixes #1855
Using the new middleware (https://github.com/cloudflare/workers-sdk/pull/1735), we implement a way of testing scheduled workers from a fetch using wra
d8a18070 Thanks @CarmenPopoviciu! - Adds support for custom _routes.json when running wrangler pages dev#1815 d8fe95d2 Thanks @cameron-robey! - feat: testing scheduled events with wrangler dev remote mode
Using the new middleware (https://github.com/cloudflare/workers-sdk/pull/1735), we implement a way of testing scheduled workers from a fetch using wrangler dev in remote mode, by passing a new command line flag --test-scheduled. This exposes a route /__scheduled which will trigger the scheduled event.
$ npx wrangler dev index.js --test-scheduled
$ curl http://localhost:8787/__scheduled
Closes https://github.com/cloudflare/workers-sdk/issues/570
#1801 07fc90d6 Thanks @rozenmd! - feat: multi-worker testing
This change introduces the ability to test multi-worker setups via the wrangler API's unstable_dev function.
Usage:
import { unstable_dev } from "wrangler";
describe("multi-worker testing", () => {
let childWorker;
let parentWorker;
beforeAll(async () => {
childWorker = await unstable_dev(
"src/child-worker.js",
{ config: "src/child-wrangler.toml" },
{ disableExperimentalWarning: true }
);
parentWorker = await unstable_dev(
"src/parent-worker.js",
{ config: "src/parent-wrangler.toml" },
{ disableExperimentalWarning: true }
);
});
afterAll(async () => {
await childWorker.stop();
await parentWorker.stop();
});
it("childWorker should return Hello World itself", async () => {
const resp = await childWorker.fetch();
if (resp) {
const text = await resp.text();
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
}
});
it("parentWorker should return Hello World by invoking the child worker", async () => {
const resp = await parentWorker.fetch();
if (resp) {
const parsedResp = await resp.text();
expect(parsedResp).toEqual("Parent worker sees: Hello World!");
}
});
});
#1865 adfc52d6 Thanks @JacobMGEvans! - polish: loglevel flag
Added a '--log-level' flag that allows the user to specify between 'debug', 'info', 'log', 'warning', 'error', 'none'
Currently 'none' will turn off all outputs in Miniflare (local mode), however, Wrangler will still output Errors.
resolves #185
3d51d553 Thanks @GregBrimble! - fix: Add 'charset' to 'Content-Type' on 'wrangler pages dev' responses5a6ccc58 Thanks @cameron-robey! - fix: handle logging of empty map/set/weak-map/weak-set` const worker = await unstable_dev( "script.js" ); const res = await worker.fetch(req); `
#1839 2660872a Thanks @cameron-robey! - feat: make it possible to specify a path for unstable_dev()'s fetch method
const worker = await unstable_dev(
"script.js"
);
const res = await worker.fetch(req);
where req can be anything from RequestInfo: string | URL | Request.
#1851 afca1b6c Thanks @cameron-robey! - feat: summary output for secret:bulk
When wrangler secret:bulk <json> is run, a summary is outputted at the end with the number of secrets successfully / unsuccessfully created.
f450e387 Thanks @rozenmd! - fix: when running wrangler init, add a test script to package.json when the user asks us to write their first test974f3311 Thanks @WalshyDev! - Add debug outputs to the exchange requestPrior to this change, if you edited your Worker via the Cloudflare Dashboard, then used CI to deploy your script, wrangler publish would fail.
#1836 3583f313 Thanks @rozenmd! - fix: wrangler publish for CI after a manual deployment
Prior to this change, if you edited your Worker via the Cloudflare Dashboard, then used CI to deploy your script, wrangler publish would fail.
This change logs a warning that your manual changes are going to be overriden, but doesn't require user input to proceed.
Closes #1832
#1644 dc1c9595 Thanks @geelen! - Deprecated --experimental-enable-local-persistence.
Added --persist and --persist-to in its place. Changed the default persistence directory to .wrangler/state, relative to wrangler.toml.
To migrate to the new flag, run mkdir -p .wrangler && mv wrangler-local-state .wrangler/state then use --persist. Alternatively, you can use --persist-to=./wrangler-local-state to keep using the files in the old location.
### Patch Changes - #1833 `b1622395` Thanks @GregBrimble! - fix: \_headers and \_redirects parsing in 'wrangler pages dev'
b1622395 Thanks @GregBrimble! - fix: _headers and _redirects parsing in 'wrangler pages dev'This fix adds a try/catch when checking when the Worker was last deployed.
#1827 32a58fee Thanks @JacobMGEvans! - fix: Publish error when deploying new Workers
This fix adds a try/catch when checking when the Worker was last deployed.
The check was failing when a Worker had never been deployed, causing deployments of new Workers to fail.
fixes #1824
#1799 a89786ba Thanks @JacobMGEvans! - feat: Bulk Secret Upload
Created a flag that allows for passing in a JSON file with key/value's of secrets.
resolve #1610
This test was asserting a hardcoded wrangler version which broke after release.
82451e9d Thanks @jspspike! - Tail now uses updated endpoint. Allows tailing workers that are above the normal "invocations per second" limit when using the --ip self filter.#1782 cc43e3c4 Thanks @jahands! - fix: Update Pages test to assert version in package.json
This test was asserting a hardcoded wrangler version which broke after release.
#1786 1af49b68 Thanks @rozenmd! - fix: refactor unstable_dev to avoid race conditions with ports
Prior to this change, wrangler would check to see if a port was available, do a bit more work, then try use that port when starting miniflare. With this change, we're using port 0 to tell Node to assign us a random free port.
To make this change work, we had to do some plumbing so miniflare can tell us the host and port it's using, so we can call fetch against it.
#1788 152a1e81 Thanks @GregBrimble! - chore: Refactor 'wrangler pages dev' to use the same code as we do in production
This will make our dev implementation an even closer simulation of production, and will make maintenance easier going forward.
#1789 b21ee41a Thanks @JacobMGEvans! - fix: getMonth compatibility date
Set correct month for compatibility_date when initializing a new Worker
resolves #1766
3fb730a3 Thanks @yjl9903! - feat: starting pages dev server doesn't require command when proxy port provided#1729 ebb5b88f Thanks @JacobMGEvans! - feat: autogenerated config from dash
Makes wrangler init's --from-dash option pull in data from Cloudflare's dashboard to generate a wrangler.toml file populated with configuration from an existing Worker.
This is a first step towards making wrangler init more useful for folks who are already using Cloudflare's products on the Dashboard.
related discussion #1623 resolves #1638
#1781 603d0b35 Thanks @JacobMGEvans! - feat: Publish Origin Messaging
feat: warn about potential conflicts during publish and init --from-dash.
resolves #1737
#1735 de29a445 Thanks @cameron-robey! - feat: new internal middleware
A new way of registering middleware that gets bundled and executed on the edge.
When generating routes for Functions projects, let's add a description so we know what wrangler version generated this config
16f051d3 Thanks @CarmenPopoviciu! - Add custom _routes.json support for Pages Functions projects#1762 23f89216 Thanks @petebacondarwin! - Use getBasePath() when trying to specify paths to files relative to the
base of the Wrangler package directory rather than trying to compute the
path from Node.js constants like **dirname and **filename. This is
because the act of bundling the source code can move the file that contains
these constants around potentially breaking the relative path to the desired files.
Fixes #1755
#1763 75f3ae82 Thanks @CarmenPopoviciu! - Add description field to _routes.json
When generating routes for Functions projects, let's add a description so we know what wrangler version generated this config
#1538 2c9caf74 Thanks @rozenmd! - chore: refactor wrangler.dev API to not need React/Ink
Prior to this change, wrangler.unstable_dev() would only support running one instance of wrangler at a time, as Ink only lets you render one instance of React. This resulted in test failures in CI.
This change creates pure JS/TS versions of these React hooks:
As a side-effect of removing React, tests should run faster in CI.
Closes #1432 Closes #1419
8163b8cf Thanks @CarmenPopoviciu! - Add unit tests for wrangler pages publishWe bump undici to version to 5.9.1 to patch some security vulnerabilities in previous versions
#1725 eb75413e Thanks @threepointone! - rename: worker_namespaces / dispatch_namespaces
The Worker-for-Platforms team would like to rename this field to more closely match what it's called internally. This fix does a search+replace on this term. This feature already had an experimental warning, and no one's using it at the moment, so we're not going to add a warning/backward compat for existing customers.
#1736 800f8553 Thanks @threepointone! - fix: do not delete previously defined plain_text/json bindings on publish
Currently, when we publish a worker, we delete an pre-existing bindings if they're not otherwise defined in wrangler.toml, and overwrite existing ones. But folks may be deploying with wrangler, and changing environment variables on the fly (like marketing messages, etc). It's annoying when deploying via wrangler blows away those values.
This patch fixes one of those issues. It will not delete any older bindings that are not in wrangler.toml. It still does overwrite existing vars, but at least this gives a way for developers to have some vars that are not blown away on every publish.
#1726 0b83504c Thanks @GregBrimble! - fix: Multiworker and static asset dev bug preventing both from being used
There was previously a collision on the generated filenames which resulted in the generated scripts looping and crashing in Miniflare with error code 7. By renaming one of the generated files, this is avoided.
#1718 02f1fe9b Thanks @threepointone! - fix: use config.dev.ip when provided
Because we'd used a default for 0.0.0.0 for the --ip flag, wrangler dev was overriding the value specified in wrangler.toml under dev.ip. This fix removes the default value (since it's being set when normalising config anyway).
Fixes https://github.com/cloudflare/workers-sdk/issues/1714
#1727 3f9e8f63 Thanks @rozenmd! - fix: refresh token when we detect that the preview session has expired (error code 10049)
When running wrangler dev, from time to time the preview session token would expire, and the dev server would need to be manually restarted. This fixes this, by refreshing the token when it expires.
Closes #1446
#1730 27ad80ee Thanks @threepointone! - feat: --var name:value and --define name:value
This enables passing values for [vars] and [define] via the cli. We have a number of usecases where the values to be injected during dev/publish aren't available statically (eg: a version string, some identifier for 3p libraries, etc) and reading those values only from wrangler.toml isn't good ergonomically. So we can now read those values when passed through the CLI.
Example: add a var during dev: wrangler dev --var xyz:123 will inject the var xyz with string "123"
(note, only strings allowed for --var)
substitute a global value: wrangler dev --define XYZ:123 will replace every global identifier XYZ with the value 123.
The same flags also work with wrangler publish.
Also, you can use actual environment vars in these commands. e.g.: wrangler dev --var xyz:$XYZ will set xyz to whatever XYZ has been set to in the terminal environment.
#1700 d7c23e49 Thanks @penalosa! - Closes #1505 by extending wrangler tail to allow for passing worker routes as well as worker script names.
For example, if you have a worker example-worker assigned to the route example.com/*, you can retrieve it's logs by running either wrangler tail example.com/* or wrangler tail example-worker—previously only wrangler tail example-worker was supported.
#1691 5b2c3ee2 Thanks @cameron-robey! - chore: bump undici and increase minimum node version to 16.13
Fixes https://github.com/cloudflare/workers-sdk/issues/1679 Fixes https://github.com/cloudflare/workers-sdk/issues/1684
Currently, if the process pages dev is proxying exists or crashes, pages dev does not clean it up, and attempts to continue proxying requests to it, r
a0a3ffde Thanks @Skye-31! - fix: pages dev correctly escapes regex characters in function paths (fixes #1685)#1628 61e3f00b Thanks @Skye-31! - fix: pages dev process exit when proxied process exits
Currently, if the process pages dev is proxying exists or crashes, pages dev does not clean it up, and attempts to continue proxying requests to it, resulting in it throwing 502 errors. This fixes that behaviour to make wrangler exit with the code the child_process exits with.
#1710 9943e647 Thanks @rozenmd! - fix: pass create-cloudflare the correct path
wrangler generate was passing create-cloudflare an absolute path, rather than a folder name, resulting in "doubled-up" paths
c18c60ee Thanks @petebacondarwin! - feat: add debug logging to CF API requests and remote dev worker requests#1663 a9f9094c Thanks @GregBrimble! - feat: Adds --compatibility-date and --compatibility-flags to wrangler pages dev
Soon to follow in production.
46b73b52 Thanks @WalshyDev! - Fixed R2 create bucket API endpoint. The wrangler r2 bucket create command should work againYour coding agent can read these notes before it upgrades. Set up the MCP server →