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
Also cleaned up when we were reading generated \_routes.json
#1655 fed80faa Thanks @jahands! - fix: Pages Functions custom _routes.json not being used
Also cleaned up when we were reading generated _routes.json
#1626 f650a0b2 Thanks @JacobMGEvans! - fix: Added pathname to the constructed URL service bindings + wrangler dev ignores pathname when making a request.
resolves #1598
af669a19 Thanks @CarmenPopoviciu! - Implement new wrangler pages functions optimize-routes command02bdfde0 Thanks @Skye-31! - fix: Handle static files with multiple extensions, e.g. /a.b should resolve /a.b.html, if /a.b as a file does not exist#1666 662dfdf9 Thanks @jahands! - fix: Consolidate routes that are over the limit to prevent failed deployments
Rather than failing a deployment because a route is too long (>100 characters), it will now be shortened to the next available level. Eg. /foo/aaaaaaa... -> /foo/*
1b232aaf Thanks @Skye-31! - fix: dev.tsx opens 127.0.0.1 instead of 0.0.0.0 (doesn't work on windows)#1656 37852672 Thanks @jahands! - fix: Warn when Pages Functions have no routes
Building/publishing pages functions with no valid handlers would result in a Functions script containing no routes, often because the user is using the functions directory for something unrelated. This will no longer add an empty Functions script to the deployment, needlessly consuming Functions quota.
c40fca42 Thanks @GregBrimble! - fix: Fix SW and Durable Object request URLs made over the service registry#1645 ac397480 Thanks @JacobMGEvans! - feat: download & initialize a wrangler project from dashboard worker
Added wrangler init --from-dash <worker-name>, which allows initializing a wrangler project from a pre-existing worker in the dashboard.
Resolves #1624 Discussion: #1623
Notes: multiplart/form-data parsing is not currently supported in Undici, so a temporary workaround to slice off top and bottom boundaries is in place.
#1639 d86382a5 Thanks @matthewdavidrodgers! - fix: support 'exceededMemory' error status in tail
While the exception for 'Worker exceeded memory limits' gets logged correctly when tailing, the actual status wasn't being counted as an error, and was falling through a switch case to 'unknown'
This ensures filtering and logging reflects that status correctly
One column per quarter.
Resolves https://github.com/cloudflare/workers-sdk/issues/1614
#1615 9163da17 Thanks @huw! - fix: Resolve source maps correctly in local dev mode
Resolves https://github.com/cloudflare/workers-sdk/issues/1614
#1609 fa8cb73f Thanks @jahands! - patch: Consolidate redundant routes when generating _routes.generated.json
Example: ["/foo/:name", "/foo/bar"] => ["/foo/*"]
#1595 d4fbd0be Thanks @caass! - Add support for Alarm Events in wrangler tail
wrangler tail --format pretty now supports receiving events from Durable Object Alarms, and will display the time the alarm was triggered.
Additionally, any future unknown events will simply print "Unknown Event" instead of crashing the wrangler process.
Closes #1519
#1642 a3e654f8 Thanks @jrf0110! - feat: Add output-routes-path to functions build
This controls the output path of the _routes.json file. Also moves _routes.json generation to tmp directory during functions build + publish
24327289 Thanks @Skye-31! - chore: make prettier also fix changesets, as it causes checks to fail if they're not formatted#1611 3df0fe04 Thanks @GregBrimble! - feat: Durable Object multi-worker bindings in local dev.
Building on the recent work for multi-worker Service bindings in local dev, this now adds support for direct Durable Object namespace bindings.
A parent (calling) Worker will look for child Workers (where the Durable Object has been defined) by matching the script_name configuration option with the child's Service name. For example, if you have a Worker A which defines a Durable Object, MyDurableObject, and Worker B which references A's Durable Object:
name = "A"
[durable_objects]
bindings = [
{ name = "MY_DO", class_name = "MyDurableObject" }
]
name = "B"
[durable_objects]
bindings = [
{ name = "REFERENCED_DO", class_name = "MyDurableObject", script_name = "A" }
]
MY_DO will work as normal in Worker A. REFERENCED_DO in Worker B will point at A's Durable Object.
Note: this only works in local mode (wrangler dev --local) at present.
2aa3fe88 Thanks @Skye-31! - fix(#1487) [pages]: Command failed: git rev-parse --abrev-ref HEAD#1602 ebd1d631 Thanks @huw! - fix: Pass usageModel to Miniflare in local dev
This allows Miniflare to dynamically update the external subrequest limit for Unbound workers.
06915ff7 Thanks @Skye-31! - fix: disallow imports in _worker.js (https://github.com/cloudflare/workers-sdk/issues/1214)#1518 85ab8a93 Thanks @jahands! - feature: Reduce Pages Functions executions for Asset-only requests in _routes.json
Manually create a _routes.json file in your build output directory to specify routes. This is a set of inclusion/exclusion rules to indicate when to run a Pages project's Functions. Note: This is an experemental feature and is subject to change.
4b04a377 Thanks @GregBrimble! - feat: Add --inspector-port argument to wrangler pages dev#1641 5f5466ab Thanks @GregBrimble! - feat: Add support for using external Durable Objects from wrangler pages dev.
An external Durable Object can be referenced using npx wrangler pages dev ./public --do MyDO=MyDurableObject@api where the Durable Object is made available on env.MyDO, and is described in a Workers service (name = "api") with the class name MyDurableObject.
You must have the api Workers service running in as another wrangler dev process elsewhere already in order to reference that object.
#1605 9e632cdd Thanks @kimyvgy! - refactor: add --ip argument for wrangler pages dev & defaults IP to 0.0.0.0
Add new argument --ip for the command wrangler pages dev, defaults to 0.0.0.0. The command wrangler dev is also defaulting to 0.0.0.0 instead of localhost.
9732fafa Thanks @WalshyDev! - Added R2 support for wrangler pages dev. You can add an R2 binding with --r2 <BINDING>.#1608 9f02758f Thanks @jrf0110! - feat: Generate _routes.generated.json for Functions routing
When using Pages Functions, a _routes.generated.json file is created to inform Pages how to route requests to a project's Functions Worker.
#1603 7ae059b3 Thanks @JacobMGEvans! - feat: R2 Object Deletequote
Improving the R2 objects management, added the functionality to delete objects in a bucket.
resolves #1584
…resource, and thus the former is being deprecated
359d0ba3 Thanks @threepointone! - chore: update esbuild to 0.14.51#1438 0a9fe918 Thanks @caass! - Initial implementation of wrangler generate
wrangler generate and wrangler generate <name> delegate to wrangler init.wrangler generate <name> <template> delegates to create-cloudflareNaming behavior is replicated from Wrangler v1, and will auto-increment the worker name based on pre-existing directories.
#1534 d3ae16cf Thanks @cameron-robey! - feat: publish full url on wrangler publish for workers.dev workers
When the url is printed out on wrangler publish, the full url is printed out so that it can be accessed from the terminal easily by doing cmd+click. Implemented only for workers.dev workers.
Resolves https://github.com/cloudflare/workers-sdk/issues/1530
f696ebb5 Thanks @petebacondarwin! - feat: add platform/os to usage metrics eventsf696ebb5 Thanks @petebacondarwin! - fix: rename pages metrics events to align better with the dashboard#1550 aca9c3e7 Thanks @cameron-robey! - feat: describe current permissions in wrangler whoami
Often users experience issues due to tokens not having the correct permissions associated with them (often due to new scopes being created for new products). With this, we print out a list of permissions associated with OAuth tokens with the wrangler whoami command to help them debug for OAuth tokens. We cannot access the permissions on an API key, so we direct the user to the location in the dashboard to achieve this.
We also cache the scopes of OAuth tokens alongside the access and refresh tokens in the .wrangler/config file to achieve this.
Currently unable to implement https://github.com/cloudflare/workers-sdk/issues/1371 - instead directs the user to the dashboard. Resolves https://github.com/cloudflare/workers-sdk/issues/1540
#1575 5b1f68ee Thanks @JacobMGEvans! - feat: legacy "kv-namespace" not supported
In previous Wrangler 1, there was a legacy configuration that was considered a "bug" and removed.
Before it was removed, tutorials, templates, blogs, etc... had utlized that configuration property to handle this in Wrangler 2 we will throw a blocking error that tell the user to utilize "kv_namespaces"
resolves #1421
#1404 17f5b576 Thanks @threepointone! - feat: add cache control options to config.assets
This adds cache control options to config.assets. This is already supported by the backing library (@cloudflare/kv-asset-handler) so we simply pass on the options at its callsite.
Additionally, this adds a configuration field to serve an app in "single page app" mode, where a root index.html is served for all html/404 requests (also powered by the same library).
#1578 cf552192 Thanks @cameron-robey! - feat: source-map function names
Following on from https://github.com/cloudflare/workers-sdk/pull/1535, using new functionality from esbuild v0.14.50 of generation of names field in generated sourcemaps, we output the original function name in the stack trace.
#1503 ebc1aa57 Thanks @threepointone! - feat: zero config multiworker development (local mode)
Preamble: Typically, a Worker has been the unit of a javascript project on our platform. Any logic that you need, you fit into one worker, ~ 1MB of javascript and bindings. If you wanted to deploy a larger application, you could define different workers on different routes. This is fine for microservice style architectures, but not all projects can be cleaved along the route boundaries; you lose out on sharing code and resources, and can still cross the size limit with heavy dependencies.
Service bindings provide a novel mechanism for composing multiple workers into a unified architecture. You could deploy shared code into a worker, and make requests to it from another worker. This lets you architect your code along functional boundaries, while also providing some relief to the 1MB size limit.
I propose a model for developing multiple bound workers in a single project.
Consider Worker A, at workers/a.js, with a wrangler.toml like so:
name = 'A'
[[services]]
binding = 'Bee'
service = 'B'
and content like so:
export default {
fetch(req, env) {
return env.Bee.fetch(req);
},
};
Consider Worker B, at workers/b.js, with a wrangler.toml like so:
name = 'B'
and content like so:
export default {
fetch(req, env) {
return new Response("Hello World");
},
};
So, a worker A, bound to B, that simply passes on the request to B.
Currently, when I run wrangler dev --local on A (or switch from remote to local mode during a dev session), and make requests to A, they'll fail because the bindings don't exist in local mode.
What I'd like, is to be able to run wrangler dev --local on B as well, and have my dev instance of A make requests to the dev instance of B. When I'm happy with my changes, I'd simply deploy both workers (again, ideally as a batched publish).
wrangler dev on a machine should start up a local service registry (if there isn't one loaded already) as a server on a well known port.(In future PRs, we'll introduce a system for doing the same with remote mode dev, as well as mixed mode. )
Related to https://github.com/cloudflare/workers-sdk/issues/1182 Fixes https://github.com/cloudflare/workers-sdk/issues/1040
#1551 1b54b54f Thanks @threepointone! - internal: middleware for modifying worker behaviour
This adds an internal mechanism for applying multiple "middleware"/facades on to workers. This lets us add functionality during dev and/or publish, where we can modify requests or env, or other ideas. (See https://github.com/cloudflare/workers-sdk/issues/1466 for actual usecases)
As part of this, I implemented a simple facade that formats errors in dev. To enable it you need to set an environment variable FORMAT_WRANGLER_ERRORS=true. This isn't a new feature we're shipping with wrangler, it's simply to demonstrate how to write middleware. We'll probably remove it in the future.
c4e6f156 Thanks @JacobMGEvans! - feat: commands added for uploading and downloading objects from r2.#1539 95d0f863 Thanks @threepointone! - fix: export durable objects correctly when using --assets
The facade for static assets doesn't export any exports from the entry point, meaning Durable Objects will fail. This fix adds all exports to the facade's exports.
69713c5c Thanks @JacobMGEvans! - chore: updated wrangler readme providing additional context on configuration, deep link to init and fixing old link to beta docs.#1581 3da184f1 Thanks @threepointone! - fix: apply multiworker dev facade only when required
This fix makes sure the multiworker dev facade is applied to the input worker only where there are other wrangler dev instances running that are bound to the input worker. We also make sure we don't apply it when we already have a binding (like in remote mode).
#1576 f696ebb5 Thanks @petebacondarwin! - feat: add metricsEnabled header to CF API calls when developing or deploying a worker
This allows us to estimate from API requests what proportion of Wrangler instances have enabled usage tracking, without breaking the agreement not to send data for those who have not opted in.
#1525 a692ace3 Thanks @threepointone! - feat: config.first_party_worker + dev facade
This introduces configuration for marking a worker as a "first party" worker, to be used inside cloudflare to develop workers. It also adds a facade that's applied for first party workers in dev.
#1545 b3424e43 Thanks @Martin-Eriksson! - fix: Throw error if both directory and command is specified for pages dev
The previous behavior was to silently ignore the command argument.
#1574 c61006ca Thanks @jahands! - fix: Retry check-missing call to make wrangler pages publish more reliable
Before uploading files in wrangler pages publish, we make a network call to check what files need to be uploaded. This call could sometimes fail, causing the publish to fail. This change will retry that network call.
#1565 2b5a2e9a Thanks @threepointone! - fix: export durable object bindings when using service bindings in dev
A similar fix to https://github.com/cloudflare/workers-sdk/pull/1539, this exports correctly when using service bindings in dev.
#1510 4dadc414 Thanks @matthewdavidrodgers! - refactor: touch up publishing to custom domains
Couple things cleaned up here:
Originally the usage of the /domains api (for publishing to custom domains) was a bit clumsy: we would attempt to optimistically publish, but the api would eagerly fail with specific error codes on why it occurred. This made for some weird control flow for retries with override flags, as well as fragile extraction of error messages.
Now we use the new /domains/changeset api to generate a changeset of actions required to get to a new state of custom domains, which informs us up front of which domains would need to be updated and overridden, and we can pass flags as needed. I do make an extra hop back to the api to lookup what the custom domains requiring updates are already attached to, but given how helpful I imagine that to be, I'm for it.
I also updated the api used for publishing the domains, from /domains to /domains/records. The latter was added to allow us to add flexibility for things like the /domains/changeset resource, and thus the former is being deprecated
f696ebb5 Thanks @petebacondarwin! - feat: send whether a Worker is using TypeScript or not in usage events#1535 eee7333b Thanks @cameron-robey! - feat: source maps support in wrangler dev remote mode
Previously stack traces from runtime errors in wrangler dev remote mode, would give unhelpful stack traces from the bundled build that was sent to the server. Here, we use source maps generated as part of bundling to provide better stack traces for errors, referencing the unbundled files.
Resolves https://github.com/cloudflare/workers-sdk/issues/1509
Fixes https://github.com/cloudflare/workers-sdk/issues/1491
#1500 0826f833 Thanks @cameron-robey! - fix: warn when using --no-bundle with --minify or --node-compat
Fixes https://github.com/cloudflare/workers-sdk/issues/1491
#1523 e1e2ee5c Thanks @threepointone! - fix: don't log version spam in tests
Currently in tests, we see a bunch of logspam from yargs about "version" being a reserved word, this patch removes that spam.
#1498 fe3fbd95 Thanks @cameron-robey! - feat: change version command to give update information
When running version command, we want to display update information if current version is not up to date. Achieved by replacing default output with the wrangler banner.
Previous behaviour (just outputting current version) reamins when !isTTY.
Version command changed from inbuilt .version() from yargs, to a regular command to allow for asynchronous behaviour.
Implements https://github.com/cloudflare/workers-sdk/issues/1492
#1431 a2e3a6b7 Thanks @Skye-31! - chore: Refactor wrangler pages dev to use Wrangler-proper's own dev server.
This:
pages dev was missing (e.g. --local-protocol),wrangler pages dev going forward.#1528 60bdc31a Thanks @threepointone! - fix: prevent local mode restart
In dev, we inject a patch for fetch() to detect bad usages. This patch is copied into the destination directory before it's used. esbuild appears to have a bug where it thinks a dependency has changed so it restarts once in local mode. The fix here is to copy the file to inject into a separate temporary dir.
Fixes https://github.com/cloudflare/workers-sdk/issues/1515
#1502 be4ffde5 Thanks @threepointone! - polish: recommend using an account id when user details aren't available.
When using an api token, sometimes the call to get a user's membership details fails with a 9109 error. In this scenario, a workaround to skip the membership check is to provide an account_id in wrangler.toml or via CLOUDFLARE_ACCOUNT_ID. This bit of polish adds this helpful tip into the error message.
7098b1ee Thanks @cameron-robey! - fix: no feedback on wrangler kv:namespace delete#1479 862f14e5 Thanks @threepointone! - fix: read process.env.NODE_ENV correctly when building worker
We replace process.env.NODE_ENV in workers with the value of the environment variable. However, we have a bug where when we make an actual build of wrangler (which has NODE_ENV set as "production"), we were also replacing the expression where we'd replace it in a worker. The result was that all workers would have process.env.NODE_ENV set to production, no matter what the user had set. The fix here is to use a "dynamic" value for the expression so that our build system doesn't replace it.
Fixes https://github.com/cloudflare/workers-sdk/issues/1477
0953af8e Thanks @JacobMGEvans! - ci: implement CodeCov Integration
CodeCov is used for analyzing code and tests to improve stability and maintainability. It does this by utilizing static code analysis
and testing output to provide insights into things that need improving, security concerns, missing test coverage of critical code, and more,
which can be missed even after exhaustive human review.#1516 e178d6fb Thanks @threepointone! - polish: don't log an error message if wrangler dev startup is interrupted.
When we quit wrangler dev, any inflight requests are cancelled. Any error handlers for those requests are ignored if the request was cancelled purposely. The check for this was missing for the prewarm request for a dev session, and this patch adds it so it dorsn't get logged to the terminal.
#1496 8eb91142 Thanks @threepointone! - fix: add fetch() dev helper correctly for pnp style package managers
In https://github.com/cloudflare/workers-sdk/pull/992, we added a dev-only helper that would warn when using fetch() in a manner that wouldn't work as expected (because of a bug we currently have in the runtime). We did this by injecting a file that would override usages of fetch(). When using pnp style package managers like yarn, this file can't be resolved correctly. So to fix that, we extract it into the temporary destination directory that we use to build the worker (much like a similar fix we did in https://github.com/cloudflare/workers-sdk/pull/1154)
Reported at https://github.com/cloudflare/workers-sdk/issues/1320#issuecomment-1188804668
#1529 1a0ac8d0 Thanks @GregBrimble! - feat: Adds the --experimental-enable-local-persistence option to wrangler pages dev
Previously, this was implicitly enabled and stored things in a .mf directory. Now we move to be in line with what wrangler dev does, defaults disabled, and stores in a wrangler-local-state directory.
#1514 9271680d Thanks @threepointone! - feat: add config.inspector_port
This adds a configuration option for the inspector port used by the debugger in wrangler dev. This also includes a bug fix where we weren't passing on this configuration to local mode.
Fixes https://github.com/cloudflare/workers-sdk/issues/1480
#1482 9eb28ec Thanks @petebacondarwin! - fix: do not ask the user for metrics permission if running in a CI
Fixes https://github.com/cloudflare/workers-sdk/issues/1480
#1482 9eb28ec Thanks @petebacondarwin! - feat: support controlling metrics gathering via WRANGLER_SEND_METRICS environment variable
Setting the WRANGLER_SEND_METRICS environment variable will override any other metrics controls,
such as the send_metrics property in wrangler.toml and cached user preference.
During a refactor, we missed enabling the inspector by default in local mode. We also broke the logic that detects the inspector url exposed by the lo
#1474 f602df7 Thanks @threepointone! - fix: enable debugger in local mode
During a refactor, we missed enabling the inspector by default in local mode. We also broke the logic that detects the inspector url exposed by the local server. This patch passes the argument correctly, fixes the detection logic. Further, it also lets you disable the inspector altogether with --inspect false, if required (for both remote and local mode).
Fixes https://github.com/cloudflare/workers-sdk/issues/1436
#1470 01f49f1 Thanks @petebacondarwin! - fix: ensure that metrics user interactions do not break other UI
The new metrics usage capture may interact with the user if they have not yet set their metrics permission. Sending metrics was being done concurrently with other commands, so there was a chance that the metrics UI broke the other command's UI. Now we ensure that metrics UI will happen synchronously.
This change adds support in Wrangler for sending usage metrics to Cloudflare. This is an opt-in only feature. We will ask the user for permission only
#1410 52fb634 Thanks @petebacondarwin! - feat: add opt-in usage metrics gathering
This change adds support in Wrangler for sending usage metrics to Cloudflare.
This is an opt-in only feature. We will ask the user for permission only once per device.
The user must grant permission, on a per device basis, before we send usage metrics to Cloudflare.
The permission can also be overridden on a per project basis by setting send_metrics = false in the wrangler.toml.
If Wrangler is running in non-interactive mode (such as in a CI job) and the user has not already given permission
we will assume that we cannot send usage metrics.
The aim of this feature is to help us learn what and how features of Wrangler (and also the Cloudflare dashboard) are being used in order to improve the developer experience.
#1463 a7ae733 Thanks @threepointone! - fix: ensure that a helpful error message is shown when on unsupported versions of node.js
Our entrypoint for wrangler (bin/wrangler.js) needs to run in older versions of node and log a message to the user that they need to upgrade their version of node. Sometimes we use syntax in this entrypoint that doesn't run in older versions of node. crashing the script and failing to log the message. This fix adds a test in CI to make sure we don't regress on that behaviour (as well as fixing the current newer syntax usage)
Fixes https://github.com/cloudflare/workers-sdk/issues/1443
#1459 4e425c6 Thanks @sidharthachatterjee! - fix: wrangler pages publish now more reliably retries an upload in case of a failure
When wrangler pages publish is run, we make calls to an upload endpoint which could be rate limited and therefore fail. We currently retry those calls after a linear backoff. This change makes that backoff exponential which should reduce the likelihood of subsequent calls being rate limited.
### Patch Changes - #1451 `62649097` Thanks @WalshyDev! - Fixed an issue where Pages upload would OOM. This was caused by us loading all the file cont
62649097 Thanks @WalshyDev! - Fixed an issue where Pages upload would OOM. This was caused by us loading all the file content into memory instead of only when required.#1375 e9e98721 Thanks @JacobMGEvans! - polish: Compliance with the XDG Base Directory Specification
Wrangler was creating a config file in the home directory of the operating system ~/.wrangler. The XDG path spec is a
standard for storing files, these changes include XDG pathing compliance for .wrangler/* location and backwards compatibility with previous
~/.wrangler locations.
resolves #1053
A message used for debugging purposes was accidentally left in, and confused some folks. Now it'll only appear when WRANGLER_LOG is set to debug.
#1389 eab9542 Thanks @caass! - Remove delegation message when global wrangler delegates to a local installation
A message used for debugging purposes was accidentally left in, and confused some
folks. Now it'll only appear when WRANGLER_LOG is set to debug.
#1447 16f9436 Thanks @threepointone! - feat: r2 support in wrangler dev --local
This adds support for r2 bindings in wrangler dev --local, powered by miniflare@2.6.0 via https://github.com/cloudflare/miniflare/pull/289.
Fixes https://github.com/cloudflare/workers-sdk/issues/1066
#1406 0f35556 Thanks @rozenmd! - fix: use fork to let wrangler know miniflare is ready
This PR replaces our use of spawn in favour of fork to spawn miniflare in wrangler's dev function. This lets miniflare let wrangler know when we're ready to send requests.
Closes #1408
#999 238b546 Thanks @caass! - Include devtools in wrangler monorepo
Previously, wrangler relied on @threepointone's built-devtools. Now, these devtools are included in the wrangler repository.
#1424 8cf0008 Thanks @caass! - fix: Check config.assets when deciding whether to include a default entry point.
An entry point isn't mandatory when using --assets, and we can use a default worker when doing so. This fix enables that same behaviour when config.assets is configured.
#1448 0d462c0 Thanks @threepointone! - polish: set checkjs: false and jsx: "react" in newly created projects
When we create a new project, it's annoying having to set jsx: "react" when that's the overwhelmingly default choice, our compiler is setup to do it automatically, and the tsc error message isn't helpful. So we set jsx: "react" in the generated tsconfig.
Setting checkJs: true is also annoying because it's not a common choice. So we set checkJs: false in the generated tsconfig.
#1450 172310d Thanks @threepointone! - polish: tweak static assets facade to log only real errors
This prevents the abundance of NotFoundErrors being unnecessaryily logged.
#1415 f3a8452 Thanks @caass! - Emit type declarations for wrangler
This is a first go-round of emitting type declarations alongside the bundled JS output, which should make it easier to use wrangler as a library.
#1433 1c1214f Thanks @threepointone! - polish: adds an actionable message when a worker name isn't provided to tail/secret
Just a better error message when a Worker name isn't available for wrangler secret or wrangler tail.
Closes https://github.com/cloudflare/workers-sdk/issues/1380
#1427 3fa5041 Thanks @caass! - Check npm_config_user_agent to guess a user's package manager
The environment variable npm_config_user_agent can be used to guess the package manager
that was used to execute wrangler. It's imperfect (just like regular user agent sniffing!)
but the package managers we support all set this property:
Before, we would warn folks that preview was deprecated in favour of dev, but then ran dev on their behalf. To avoid maintaining effectively two versi…
#992 ee6b413 Thanks @petebacondarwin! - fix: add warning to fetch() calls that will change the requested port
In Workers published to the Edge (rather than previews) there is a bug where a custom port on a downstream fetch request is ignored, defaulting to the standard port.
For example, https://my.example.com:668 will actually send the request to https://my.example.com:443.
This does not happen when using wrangler dev (both in remote and local mode), but to ensure that developers are aware of it this change displays a runtime warning in the console when the bug is hit.
Closes #1320
#1378 2579257 Thanks @rozenmd! - chore: fully deprecate the preview command
Before, we would warn folks that preview was deprecated in favour of dev, but then ran dev on their behalf.
To avoid maintaining effectively two versions of the dev command, we're now just telling folks to run dev.
#1213 1bab3f6 Thanks @threepointone! - fix: pass routes to dev session
We can pass routes when creating a dev session. The effect of this is when you visit a path that doesn't match the given routes, then it instead does a fetch from the deployed worker on that path (if any). We were previously passing */*, i.e, matching all routes in dev; this fix now passes configured routes instead.
#1374 215c4f0 Thanks @threepointone! - feat: commands to manage worker namespaces
This adds commands to create, delete, list, and get info for "worker namespaces" (name to be bikeshed-ed). This is based on work by @aaronlisman in https://github.com/cloudflare/workers-sdk/pull/1310.
#1403 9c6c3fb Thanks @threepointone! - feat: config.no_bundle as a configuration option to prevent bundling
As a configuration parallel to --no-bundle (introduced in https://github.com/cloudflare/workers-sdk/pull/1300 as --no-build, renamed in https://github.com/cloudflare/workers-sdk/pull/1399 to --no-bundle), this introduces a configuration field no_bundle to prevent bundling of the worker before it's published. It's inheritable, which means it can be defined inside environments as well.
#1355 61c31a9 Thanks @williamhorning! - fix: Fallback to non-interactive mode on error
If the terminal isn't a TTY, fallback to non-interactive mode instead of throwing an error. This makes it so users of Bash on Windows can pipe to wrangler without an error being thrown.
resolves #1303
#1337 1d778ae Thanks @JacobMGEvans! - polish: bundle reporter was not printing during publish errors
The reporter is now called before the publish API call, printing every time.
resolves #1328
#1393 b36ef43 Thanks @threepointone! - chore: enable node's experimental fetch flag
We'd previously had some funny behaviour with undici clashing with node's own fetch supporting classes, and had turned off node's fetch implementation. Recent updates to undici appear to have fixed the issue, so let's turn it back on.
Closes https://github.com/cloudflare/workers-sdk/issues/834
#1335 49cf17e Thanks @JacobMGEvans! - feat: resolve --assets cli arg relative to current working directory
Before we were resolving the Asset directory relative to the location of wrangler.toml at all times.
Now the --assets cli arg is resolved relative to current working directory.
resolves #1333
#1350 dee034b Thanks @rozenmd! - feat: export an (unstable) function that folks can use in their own scripts to invoke wrangler's dev CLI
Closes #1350
#1401 6732d95 Thanks @threepointone! - fix: log pubsub beta usage warnings consistently
This fix makes sure the pubsub beta warnings are logged consistently, once per help menu, through the hierarchy of its command tree.
Fixes https://github.com/cloudflare/workers-sdk/issues/1370
#1386 4112001 Thanks @rozenmd! - feat: implement fetch for wrangler's unstable_dev API, and write our first integration test.
Prior to this PR, users of unstable_dev had to provide their own fetcher, and guess the address and port that the wrangler dev server was using.
With this implementation, it's now possible to test wrangler, using just wrangler (and a test framework):
describe("worker", async () => {
const worker = await wrangler.unstable_dev("src/index.ts");
const resp = await worker.fetch();
expect(resp).not.toBe(undefined);
if (resp) {
const text = await resp.text();
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
}
worker.stop();
}
Closes #1383 Closes #1384 Closes #1385
#1399 1ab71a7 Thanks @threepointone! - fix: rename --no-build to --no-bundle
This fix renames the --no-build cli arg to --no-bundle. no-build wasn't a great name because it would imply that we don't run custom builds specified under [build] which isn't true. So we rename closer to what wrangler actually does, which is bundling the input. This also makes it clearer that it's a single file upload.
8201733 Thanks @Maximo-Guk! - Throw error if user attempts to use config with pages#1398 ecfbb0c Thanks @threepointone! - Added support for pubsub namespace (via @elithrar in https://github.com/cloudflare/workers-sdk/pull/1314)
This adds support for managing pubsub namespaces and brokers (https://developers.cloudflare.com/pub-sub/)
#1348 eb948b0 Thanks @threepointone! - polish: add an experimental warning if --assets is used
We already have a warning when config.assets is used, this adds it for the cli argument as well.
#1326 12f2703 Thanks @timabb031! - fix: show console.error/console.warn logs when using dev --local.
Prior to this change, logging with console.error/console.warn in a Worker wouldn't output anything to the console when running in local mode. This was happening because stderr data event handler was being removed after the Debugger listening... string was found.
This change updates the stderr data event handler to forward on all events to process.stderr.
Closes #1324
#1309 e5a6aca Thanks @petebacondarwin! - style: convert all source code indentation to tabs
Fixes #1298
#1395 88f2702 Thanks @threepointone! - feat: cache account id selection
This adds caching for account id fetch/selection for all wrangler commands.
Currently, if we have an api/oauth token, but haven't provided an account id, we fetch account information from cloudflare. If a user has just one account id, we automatically choose that. If there are more than one, then we show a dropdown and ask the user to pick one. This is convenient, and lets the user not have to specify their account id when starting a project.
However, if does make startup slow, since it has to do that fetch every time. It's also annoying for folks with multiple account ids because they have to pick their account id every time.
So we now cache the account details into node_modules/.cache/wrangler (much like pages already does with account id and project name).
This patch also refactors config-cache.ts; it only caches if there's a node_modules folder, and it looks for the closest node_modules folder (and not directly in cwd). I also added tests for when a node_modules folder isn't available. It also trims the message that we log to terminal.
Closes https://github.com/cloudflare/workers-sdk/issues/300
#1391 ea7ee45 Thanks @threepointone! - fix: create a single session during remote dev
Previously, we would be creating a fresh session for every script change during remote dev. While this worked, it makes iterating slower, and unnecessarily discards state. This fix makes it so we create only a single session for remote dev, and reuses that session on every script change. This also means we can use a single script id for every worker in a session (when a name isn't already given). Further, we also make the prewarming call of the preview space be non-blocking.
Fixes https://github.com/cloudflare/workers-sdk/issues/1191
#1365 b9f7200 Thanks @threepointone! - fix: normalise account_id = '' to account_id: undefined
In older templates, (i.e made for Wrangler v1.x), account_id ='' is considered as a valid input, but then ignored. With Wrangler 2, when running wrangler dev, we log an error, but it fixes itself after we get an account id. Much like https://github.com/cloudflare/wrangler2/issues/1329, the fix here is to normalise that value when we see it, and replace it with undefined while logging a warning.
This fix also tweaks the messaging for a blank route value to suggest some user action.
cd66b67 Thanks @SirCremefresh! - Updated eslint to version 0.14.47b2c2c2b Thanks @petebacondarwin! - fix: display email from process env in whoami and display better error when lacking permissions#1300 dcffc93 Thanks @threepointone! - feat: publish --no-build
This adds a --no-build flag to wrangler publish. We've had a bunch of people asking to be able to upload a worker directly, without any modifications. While there are tradeoffs to this approach (any linked modules etc won't work), we understand that people who need this functionality are aware of it (and the usecases that have presented themselves all seem to match this).
#1392 ff2e7cb Thanks @threepointone! - fix: keep site upload batches under 98 mb
The maximum request size for a batch upload is 100 MB. We were previously calculating the upload key value to be under 100 MiB. Further, with a few bytes here and there, the size of the request can exceed 100 MiB. So this fix calculate using MB instead of MiB, but also brings down our own limit to 98 MB so there's some wiggle room for uploads.
Fixes https://github.com/cloudflare/workers-sdk/issues/1367
#1377 a6f1cee Thanks @threepointone! - feat: bind a worker with [worker_namespaces]
This feature les you bind a worker to a dynamic dispatch namespaces, which may have other workers bound inside it. (See https://blog.cloudflare.com/workers-for-platforms/). Inside your wrangler.toml, you would add
[[worker_namespaces]]
binding = 'dispatcher' # available as env.dispatcher in your worker
namespace = 'namespace-name' # the name of the namespace being bound
Based on work by @aaronlisman in https://github.com/cloudflare/workers-sdk/pull/1310
#1297 40036e2 Thanks @threepointone! - feat: implement config.define
This implements config.define. This lets the user define a map of keys to strings that will be substituted in the worker's source. This is particularly useful when combined with environments. A common usecase is for values that are sent along with metrics events; environment name, public keys, version numbers, etc. It's also sometimes a workaround for the usability of module env vars, which otherwise have to be threaded through request function stacks.
8d68226 Thanks @threepointone! - feat: add support for pubsub commands (via @elithrar and @netcli in https://github.com/cloudflare/workers-sdk/pull/1314)#1351 c770167 Thanks @geelen! - feat: add support for CLOUDFLARE_API_KEY + CLOUDFLARE_EMAIL to authorise
This adds support for using the CLOUDFLARE_API_KEY + CLOUDFLARE_EMAIL env vars for authorising a user. This also adds support for CF_API_KEY + CF_EMAIL from Wrangler v1, with a deprecation warning.
#1352 4e03036 Thanks @JacobMGEvans! - bugfix: Allow route setting to be ""
Previously Wrangler v1 behavior had allowed for route = "". To keep parity it will be possible to set route = "" in the config file and represent not setting a route, while providing a warning.
resolves #1329
4ad084e Thanks @sbquinlan! - feature By @sbquinlan: Set "upstream" miniflare option when running dev in local mode5cc0772 Thanks @Maximo-Guk! - Added .dev.vars support for pagesThis logs the complete bundle size of the Worker (as well as when compressed) during publish and dev.
#1272 f7d362e Thanks @JacobMGEvans! - feat: print bundle size during publish and dev
This logs the complete bundle size of the Worker (as well as when compressed) during publish and dev.
Via https://github.com/cloudflare/workers-sdk/issues/405#issuecomment-1156762297)
#1287 2072e27 Thanks @f5io! - fix: kv:key put/get binary file
As raised in https://github.com/cloudflare/workers-sdk/issues/1254, it was discovered that binary uploads were being mangled by wrangler 2, whereas they worked in wrangler 1. This is because they were read into a string by providing an explicit encoding of utf-8. This fix reads provided files into a node Buffer that is then passed directly to the request.
Subsequently https://github.com/cloudflare/workers-sdk/issues/1273 was raised in relation to a similar issue with gets from wrangler 2. This was happening due to the downloaded file being converted to utf-8 encoding as it was pushed through console.log. By leveraging process.stdout.write we can push the fetched ArrayBuffer to std out directly without inferring any specific encoding value.
bcd066d Thanks @sidharthachatterjee! - fix: Ensure Response is mutable in Pages functions#1265 e322475 Thanks @petebacondarwin! - fix: support all git versions for wrangler init
If git does not support the --initial-branch argument then just fallback to the default initial branch name.
We tried to be more clever about this but there are two many weird corner cases with different git versions on different architectures.
Now we do our best, with recent versions of git, to ensure that the branch is called main but otherwise just make sure we don't crash.
Fixes #1228
#1311 374655d Thanks @JacobMGEvans! - feat: add --text flag to decode kv:key get response values as utf8 strings
Previously, all kv values were being rendered directly as bytes to the stdout, which makes sense if the value is a binary blob that you are going to pipe into a file, but doesn't make sense if the value is a simple string.
resolves #1306
#1327 4880d54 Thanks @JacobMGEvans! - feat: resolve --site cli arg relative to current working directory
Before we were resolving the Site directory relative to the location of wrangler.toml at all times.
Now the --site cli arg is resolved relative to current working directory.
resolves #1243
#1270 7ed5e1a Thanks @caass! - Delegate to a local install of wrangler if one exists.
Users will frequently install wrangler globally to run commands like wrangler init, but we also recommend pinning a specific version of wrangler in a project's package.json. Now, when a user invokes a global install of wrangler, we'll check to see if they also have a local installation. If they do, we'll delegate to that version.
#1289 0d6098c Thanks @threepointone! - feat: entry point is not mandatory if --assets is passed
Since we use a facade worker with --assets, an entry point is not strictly necessary. This makes a common usecase of "deploy a bunch of static assets" extremely easy to start, as a one liner npx wrangler dev --assets path/to/folder (and same with publish).
#1293 ee57d77 Thanks @petebacondarwin! - fix: do not crash in wrangler dev if user has multiple accounts
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).
This fix refactors the ChooseAccount component so that it can be used directly within another component.
Fixes #1258
0fd0c30 Thanks @threepointone! - polish: include a copy-pastable message when trying to publish without a compatibility date#1269 fea87cf Thanks @petebacondarwin! - fix: do not consider ancestor files when initializing a project with a specified name
When initializing a new project (via wrangler init) we attempt to reuse files in the current
directory, or in an ancestor directory. In particular we look up the directory tree for
package.json and tsconfig.json and use those instead of creating new ones.
Now we only do this if you do not specify a name for the new Worker. If you do specify a name, we now only consider files in the directory where the Worker will be initialized.
Fixes #859
#1321 8e2b92f Thanks @GregBrimble! - fix: Correctly resolve directories for 'wrangler pages publish'
Previously, attempting to publish a nested directory or the current directory would result in parsing mangled paths which broke deployments. This has now been fixed.
#1293 ee57d77 Thanks @petebacondarwin! - fix: do not hang waiting for account choice when in non-interactive mode
The previous tests for non-interactive only checked the stdin.isTTY, but
you can have scenarios where the stdin is interactive but the stdout is not.
For example when writing the output of a kv:key get command to a file.
We now check that both stdin and stdout are interactive before trying to interact with the user.
#1294 f6836b0 Thanks @threepointone! - fix: serve --assets in dev + local mode
A quick bugfix to make sure --assets/config.assets gets served correctly in dev --local.
#1237 e1b8ac4 Thanks @threepointone! - feat: --assets / config.assets to serve a folder of static assets
This adds support for defining assets in wrangler.toml. You can configure it with a string path, or a {bucket, include, exclude} object (much like [site]). This also renames the --experimental-public arg as --assets.
Via https://github.com/cloudflare/workers-sdk/issues/1162
`a4ba42a` Thanks @threepointone! - Revert "Take 2 at moving .npmrc to the root of the repository (#1281)"
a4ba42a Thanks @threepointone! - Revert "Take 2 at moving .npmrc to the root of the repository (#1281)"
#1267 c667398 Thanks @rozenmd! - fix: let folks know the URL we're opening during login
Closes #1259
d8ee04f Thanks @threepointone! - fix: pass env and ctx to request handler when using --experimental-public1b068c9 Thanks @threepointone! - Revert "fix: kv:key put upload binary files fix (#1255)"This fixes the parsing of the url returned by Node Inspector via stderr which could be received partially in multiple chunks or in a single chunk.
#1229 e273e09 Thanks @timabb031! - fix: parsing of node inspector url
This fixes the parsing of the url returned by Node Inspector via stderr which could be received partially in multiple chunks or in a single chunk.
Closes #1226
#1255 2d806dc Thanks @f5io! - fix: kv:key put binary file upload
As raised in https://github.com/cloudflare/workers-sdk/issues/1254, it was discovered that binary uploads were being mangled by Wrangler v2, whereas they worked in Wrangler v1. This is because they were read into a string by providing an explicit encoding of utf-8. This fix reads provided files into a node Buffer that is then passed directly to the request.
#1248 db8a0bb Thanks @threepointone! - fix: instruct api to exclude script content on worker upload
When we upload a script bundle, we get the actual content of the script back in the response. Sometimes that script can be large (depending on whether the upload was large), and currently it may even be a badly escaped string. We can pass a queryparam excludeScript that, as it implies, exclude the script content in the response. This fix does that.
Fixes https://github.com/cloudflare/workers-sdk/issues/1222
#1253 eee5c78 Thanks @threepointone! - fix: resolve asset handler for --experimental-path
In https://github.com/cloudflare/workers-sdk/pull/1241, we removed the vendored version of @cloudflare/kv-asset-handler, as well as the build configuration that would point to the vendored version when compiling a worker using --experimental-public. However, wrangler can be used where it's not installed in the package.json for the worker, or even when there's no package.json at all (like when wrangler is installed globally, or used with npx). In this situation, if the user doesn't have @cloudflare/kv-asset-handler installed, then building the worker will fail. We don't want to make the user install this themselves, so instead we point to a barrel import for the library in the facade for the worker.
#1234 3e94bc6 Thanks @threepointone! - feat: support --experimental-public in local mode
--experimental-public is an abstraction over Workers Sites, and we can leverage miniflare's inbuilt support for Sites to serve assets in local mode.
#1236 891d128 Thanks @threepointone! - fix: generate site assets manifest relative to site.bucket
We had a bug where we were generating asset manifest keys incorrectly if we ran wrangler from a different path to wrangler.toml. This fixes the generation of said keys, and adds a test for it.
Fixes #1235
#1216 4eb70f9 Thanks @JacobMGEvans! - feat: reload server on configuration changes, the values passed into the server during restart will be bindings
resolves #439
#1231 5206c24 Thanks @threepointone! - feat: build.watch_dir can be an array of paths
In projects where:
...we'd like to be able to specify multiple paths for custom builds, (the config build.watch_dir config). This patch enables such behaviour. It now accepts a single path as before, or optionally an array of strings/paths.
Fixes https://github.com/cloudflare/workers-sdk/issues/1095
#1241 471cfef Thanks @threepointone! - use @cloudflare/kv-asset-handler for --experimental-public
We'd previously vendored in @cloudflare/kv-asset-handler and mime for --experimental-public. We've since updated @cloudflare/kv-asset-handler to support module workers correctly, and don't need the vendored versions anymore. This patch uses the lib as a dependency, and deletes the vendor folder.
As reported in https://github.com/cloudflare/workers-sdk/issues/1189, we're including the name of the folder in the keys of the KV store that stores t
#1239 df55709 Thanks @threepointone! - polish: don't include folder name in Sites kv asset keys
As reported in https://github.com/cloudflare/workers-sdk/issues/1189, we're including the name of the folder in the keys of the KV store that stores the assets. This doesn't match v1 behaviour. It makes sense not to include these since, we should be able to move around the folder and not have to reupload the entire folder again.
Fixes https://github.com/cloudflare/workers-sdk/issues/1189
#1210 785d418 Thanks @GregBrimble! - feat: Upload the delta for wrangler pages publish
We now keep track of the files that make up each deployment and intelligently only upload the files that we haven't seen. This means that similar subsequent deployments should only need to upload a minority of files and this will hopefully make uploads even faster.
#1195 66a85ca Thanks @threepointone! - fix: batch sites uploads in groups under 100mb
There's an upper limit on the size of an upload to the bulk kv put api (as specified in https://api.cloudflare.com/#workers-kv-namespace-write-multiple-key-value-pairs). This patch batches sites uploads staying under the 100mb limit.
Fixes https://github.com/cloudflare/workers-sdk/issues/1187
#1218 f8a21ed Thanks @threepointone! - fix: warn on unexpected fields on config.triggers
This adds a warning when we find unexpected fields on the triggers config (and any future fields that use the isObjectWith() validation helper)
When generating a preview session on the edge with wrangler dev, for a zoned worker we were using a random id as the script ID. This would make the ba
#1192 bafa5ac Thanks @threepointone! - fix: use worker name as a script ID when generating a preview session
When generating a preview session on the edge with wrangler dev, for a zoned worker we were using a random id as the script ID. This would make the backend not associate the dev session with any resources that were otherwise assigned to the script (specifically for secrets, but other stuff as well) The fix is simply to use the worker name (when available) as the script ID.
Fixes https://github.com/cloudflare/workers-sdk/issues/1003 Fixes https://github.com/cloudflare/workers-sdk/issues/1172
#1212 101342e Thanks @petebacondarwin! - fix: do not crash when not logged in and switching to remote dev mode
Previously, if you are not logged in when running wrangler dev it will only try to log you in
if you start in "remote" mode. In "local" mode there is no need to be logged in, so it doesn't
bother to try to login, and then will crash if you switch to "remote" mode interactively.
The problem was that we were only attempting to login once before creating the <Remote> component.
Now this logic has been moved into a useEffect() inside <Remote> so that it will be run whether
starting in "remote" or transitioning to "remote" from "local".
The fact that the check is no longer done before creating the components is proven by removing the
mockAccountId() and mockApiToken() calls from the dev.test.ts files.
Fixes #18
#1188 b44cc26 Thanks @petebacondarwin! - fix: fallback on old zone-based API when account-based route API fails
While we wait for changes to the CF API to support API tokens that do not have "All Zone" permissions, this change provides a workaround for most scenarios.
If the bulk-route request fails with an authorization error, then we fallback to the Wrangler v1 approach, which sends individual route updates via a zone-based endpoint.
Fixes #651
e64812e Thanks @sidharthachatterjee! - fix: Refresh JWT in wrangler pages publish when it expires#1209 2d42882 Thanks @petebacondarwin! - fix: ensure wrangler init works with older versions of git
Rather than using the recently added --initial-branch option, we now just renamed the initial branch using git branch -m main.
Fixes https://github.com/cloudflare/workers-sdk/issues/1168
When wrangler init is used to create a new Scheduled Worker a cron trigger (1 \* \* \* \*) will be added to wrangler.toml, but only if wrangler.toml i
#1184 4a10176 Thanks @timabb031! - polish: add cron trigger to wrangler.toml when new Scheduled Worker is created
When wrangler init is used to create a new Scheduled Worker a cron trigger (1 * * * *) will be added to wrangler.toml, but only if wrangler.toml is being created during init. If wrangler.toml exists prior to running wrangler init then wrangler.toml will remain unchanged even if the user selects the "Scheduled Handler" option. This is as per existing tests in init.test.ts that ensure wrangler.toml is never overwritten after agreeing to prompts. That can change if it needs to.
#1163 52c0bf0 Thanks @threepointone! - fix: only log available bindings once in dev
Because we were calling printBindings during the render phase of <Dev/>, we were logging the bindings multiple times (render can be called multiple times, and the interaction of Ink's stdout output intermingled with console is a bit weird). We could have put it into an effect, but I think a better solution here is to simply log it before we even start rendering <Dev/> (so we could see the bindings even if Dev fails to load, for example).
This also adds a fix that masks any overriden values so that we don't accidentally log potential secrets into the terminal.
#1153 40f20b2 Thanks @petebacondarwin! - fix: minify and node_compat should be inherited
Fixes #1150
ea8f8d7 Thanks @sidharthachatterjee! - fix: Ignore .git when publishing a Pages project#1171 de4e3c2 Thanks @petebacondarwin! - fix: link to the issue chooser in GitHub
Previously, when an error occurs, wrangler says:
If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new.
Now, it links through to the issue template chooser which is more helpful.
Fixes #1169
#1154 5d6de58 Thanks @threepointone! - fix: extract Cloudflare_CA.pem to temp dir before using it
With package managers like yarn, the cloudflare cert won't be available on the filesystem as expected (since the module is inside a .zip file). This fix instead extracts the file out of the module, copies it to a temporary directory, and directs node to use that as the cert instead, preventing warnings like https://github.com/cloudflare/workers-sdk/issues/1136.
Fixes https://github.com/cloudflare/workers-sdk/issues/1136
#1166 08e3a49 Thanks @threepointone! - fix: warn on unexpected fields on migrations
This adds a warning for unexpected fields on [migrations] config, reported in https://github.com/cloudflare/workers-sdk/issues/1165. It also adds a test for incorrect renamed_classes in a migration.
ee0c380 Thanks @danbulant! - feat: add pnpm support6187f36 Thanks @petebacondarwin! - fix: backslash on manifest keys in windowse452a35 Thanks @sidharthachatterjee! - fix: Skip cfFetch if there are no functions during pages dev#1122 c2d2f44 Thanks @petebacondarwin! - fix: display chained errors from the CF API
For example if you have an invalid CF_API_TOKEN and try running wrangler whoami
you now get the additional 6111 error information:
✘ [ERROR] A request to the Cloudflare API (/user) failed.
Invalid request headers [code: 6003]
- Invalid format for Authorization header [code: 6111]
cec0657 Thanks @petebacondarwin! - refactor: add User-Agent to all CF API requests#1152 b817136 Thanks @threepointone! - polish: Give a copy-paste config when [migrations] are missing
This gives a slightly better message when migrations are missing for declared durable objcts. Specifically, it gives a copy-pastable section to add to wrangler.toml, and doesn't show the warning at all for invalid class names anymore.
Partially makes https://github.com/cloudflare/workers-sdk/issues/1076 better.
#1141 a8c509a Thanks @rozenmd! - fix: rename "publish" package.json script to "deploy"
Renaming the default "publish" package.json script to "deploy" to avoid confusion with npm's publish command.
Closes #1121
#1175 e978986 Thanks @timabb031! - feature: allow user to select a handler template with wrangler init
This allows the user to choose which template they'd like to use when they are prompted to create a new worker.
The options are currently "None"/"Fetch Handler"/"Scheduled Handler".
Support for new handler types such as email can be added easily in future.
c2d2f44 Thanks @petebacondarwin! - fix: improve error message when CF API responds with an errorConfigures the undici library (the library wrangler uses for fetch) to send all requests via a proxy selected from the first non-empty environment var
515a52f Thanks @rozenmd! - fix: print instructions even if installPackages fails to fetch npm packages#1051 7e2e97b Thanks @rozenmd! - feat: add support for using wrangler behind a proxy
Configures the undici library (the library wrangler uses for fetch) to send all requests via a proxy selected from the first non-empty environment variable from "https_proxy", "HTTPS_PROXY", "http_proxy" and "HTTP_PROXY".
#1089 de59ee7 Thanks @rozenmd! - fix: batch package manager installs so folks only have to wait once
When running wrangler init, we install packages as folks confirm their options.
This disrupts the "flow", particularly on slower internet connections.
To avoid this disruption, we now only install packages once we're done asking questions.
Closes #1036
#1073 6bb2564 Thanks @caass! - Add a better message when a user doesn't have a Chromium-based browser.
Certain functionality we use in wrangler depends on a Chromium-based browser. Previously, we would throw a somewhat arcane error that was hard (or impossible) to understand without knowing what we needed. While ideally all of our functionality would work across all major browsers, as a stopgap measure we can at least inform the user what the actual issue is.
Additionally, add support for Brave as a Chromium-based browser.
#1079 fb0dec4 Thanks @caass! - Print the bindings a worker has access to during dev and publish
It can be helpful for a user to know exactly what resources a worker will have access to and where they can access them, so we now log the bindings available to a worker during wrangler dev and wrangler publish.
#1097 c73a3c4 Thanks @petebacondarwin! - fix: ensure all line endings are normalized before parsing as TOML
Only the last line-ending was being normalized not all of them.
Fixes https://github.com/cloudflare/workers-sdk/issues/1094
#1111 1eaefeb Thanks @JacobMGEvans! - Git default main branch
polish: Default branch when choosing to initialize a git repository will now be main.
This is inline with current common industry ethical practices.
See:
#1058 1a59efe Thanks @threepointone! - refactor: detect missing [migrations] during config validation
This does a small refactor -
[migrations] were defined in the presence of [durable_objects], and warning if not. This moves it into the config validation step, which means it'll check for all commands (but notably dev)dev.#1090 85fbfe8 Thanks @petebacondarwin! - refactor: remove use of any
This "quick-win" refactors some of the code to avoid the use of any where possible.
Using any can cause type-checking to be disabled across the code in unexpectedly wide-impact ways.
There is one other use of any not touched here because it is fixed by #1088 separately.
#1088 d63d790 Thanks @petebacondarwin! - fix: ensure that the proxy server shuts down to prevent wrangler dev from hanging
When running wrangler dev we create a proxy to the actual remote Worker.
After creating a connection to this proxy by a browser request the proxy did not shutdown.
Now we use a HttpTerminator helper library to force the proxy to close open connections and shutdown correctly.
Fixes #958
#1099 175737f Thanks @petebacondarwin! - fix: delegate wrangler build to wrangler publish
Since wrangler publish --dry-run --outdir=dist is basically the same result
as what Wrangler v1 did with wrangler build let's run that for the user if
they try to run wrangler build.
8070763 Thanks @rozenmd! - fix: friendlier error for when a subdomain hasn't been configured in dev mode15e5c12 Thanks @timabb031! - chore: updated new worker ts template with env/ctx parameters and added Env interface#1080 4a09c1b Thanks @caass! - Improve messaging when bulk deleting or uploading KV Pairs
Closes #555
#1000 5a8e8d5 Thanks @JacobMGEvans! - pages dev <dir> & wrangler pages functions build will have a --node-compat flag powered by @esbuild-plugins/node-globals-polyfill (which in itself is powered by rollup-plugin-node-polyfills). The only difference in pages will be it does not check the wrangler.toml so the node_compat = truewill not enable it for wrangler pages functionality.
resolves #890
#1028 b7a9ce6 Thanks @GregBrimble! - feat: Use new bulk upload API for 'wrangler pages publish'
This raises the file limit back up to 20k for a deployment.
This removes the scary uppercase from DEPRECATION warnings. It also moves the service environment usage warning into diagnostics instead of logging it…
#1018 cd2c42f Thanks @threepointone! - fix: strip leading */*. from routes when deducing a host for dev
When given routes, we use the host name from the route to deduce a zone id to pass along with the host to set with dev session. Route patterns can include leading */*., which we don't account for when deducing said zone id, resulting in subtle errors for the session. This fix strips those leading characters as appropriate.
Fixes https://github.com/cloudflare/workers-sdk/issues/1002
#1044 7a191a2 Thanks @JacobMGEvans! - fix: trim trailing whitespace from the secrets before uploading
resolves #993
#1052 233eef2 Thanks @petebacondarwin! - fix: display the correct help information when a subcommand is invalid
Previously, when an invalid subcommand was used, such as wrangler r2 foo,
the help that was displayed showed the top-level commands prefixed by the command in used.
E.g.
wrangler r2 init [name] 📥 Create a wrangler.toml configuration file
wrangler r2 dev [script] 👂 Start a local server for developing your worker
wrangler r2 publish [script] 🆙 Publish your Worker to Cloudflare.
...
Now the correct command help is displayed:
$ wrangler r2 foo
✘ [ERROR] Unknown argument: foo
wrangler r2
📦 Interact with an R2 store
Commands: wrangler r2 bucket Manage R2 buckets
Flags: -c, --config Path to .toml configuration file [string] -h, --help Show help [boolean] -v, --version Show version number [boolean]
Fixes #871
* [#906](https://github.com/cloudflare/workers-sdk/pull/906) [`3279f10`](https://github.com/cloudflare/workers-sdk/commit/3279f103fb3b1c27addb4c69c30ad970ab0d5f77) Thanks [@threepointone](https://github.com/threepointone)! - feat: implement support for service bindings
This adds experimental support for service bindings, aka worker-to-worker bindings. It's lets you "call" a worker from another worker, without incurring any network cost, and (ideally) with much less latency. To use it, define a `[services]` field in `wrangler.toml`, which is a map of bindings to worker names (and environment). Let's say you already have a worker named "my-worker" deployed. In another worker's configuration, you can create a service binding to it like so:
```toml
[[services]]
binding = "MYWORKER"
service = "my-worker"
environment = "production" # optional, defaults to the worker's `default_environment` for now
And in your worker, you can call it like so:
export default {
fetch(req, env, ctx) {
return env.MYWORKER.fetch(new Request("http://domain/some-path"));
},
};
Fixes https://github.com/cloudflare/workers-sdk/issues/1026
#1045 8eeef9a Thanks @jrf0110! - fix: Incorrect extension extraction from file paths.
Our extension extraction logic was taking into account folder names, which can include periods. The logic would incorrectly identify a file path of .well-known/foo as having the extension of well-known/foo when in reality it should be an empty string.
#1039 95852c3 Thanks @threepointone! - fix: don't fetch migrations when in --dry-run mode
Fixes https://github.com/cloudflare/workers-sdk/issues/1038
#1033 ffce3e3 Thanks @petebacondarwin! - fix: wrangler init should not crash if Git is not available on Windows
We check for the presence of Git by trying to run git --version.
On non-Windows we get an Error with code set to "ENOENT".
One Windows we get a different error:
{
"shortMessage":"Command failed with exit code 1: git --version",
"command":"git --version",
"escapedCommand":"git --version",
"exitCode":1,
"stdout":"",
"stderr":"'git' is not recognized as an internal or external command,\r\noperable program or batch file.",
"failed":true,
"timedOut":false,
"isCanceled":false,
"killed":false
}
Since we don't really care what the error is, now we just assume that Git is not available if an error is thrown.
Fixes #1022
#982 6791703 Thanks @matthewdavidrodgers! - feature: add support for publishing to Custom Domains
With the release of Custom Domains for workers, users can publish directly to a custom domain on a route, rather than creating a dummy DNS record first and manually pointing the worker over - this adds the same support to wrangler.
Users declare routes as normal, but to indicate that a route should be treated as a custom domain, a user simply uses the object format in the toml file, but with a new key: custom_domain (i.e. routes = [{ pattern = "api.example.com", custom_domain = true }])
When wrangler sees a route like this, it peels them off from the rest of the routes and publishes them separately, using the /domains api. This api is very defensive, erroring eagerly if there are conflicts in existing Custom Domains or managed DNS records. In the case of conflicts, wrangler prompts for confirmation, and then retries with parameters to indicate overriding is allowed.
#1019 5816eba Thanks @threepointone! - feat: bind a durable object by environment
For durable objects, instead of just { name, class_name, script_name}, this lets you bind by environment as well, like so { name, class_name, script_name, environment }.
Fixes https://github.com/cloudflare/workers-sdk/issues/996
#1057 608dcd9 Thanks @petebacondarwin! - fix: pages "command" can consist of multiple words
On Windows, the following command wrangler pages dev -- foo bar would error
saying that bar was not a known argument. This is because foo and bar are
passed to Yargs as separate arguments.
A workaround is to put the command in quotes: wrangler pages dev -- "foo bar".
But this fix makes the command argument variadic, which also solves the problem.
Fixes #965
3545e41 Thanks @rozenmd! - feat: trying to use node builtins should recommend you enable node_compat in wrangler.toml#1024 110f340 Thanks @threepointone! - polish: validate payload for kv:bulk put on client side
This adds client side validation for the paylod for kv:bulk put, importantly ensuring we're uploading only string key/value pairs (as well as validation for the other fields).
Fixes https://github.com/cloudflare/workers-sdk/issues/571
556e6dd Thanks @threepointone! - chore: bump to do a release#987 bb94038 Thanks @threepointone! - fix: encode key when calling kv:ket get, don't encode when deleting a namespace
This cleans up some logic from https://github.com/cloudflare/workers-sdk/pull/964.
KV to all the KV-related function nameskv:namespace delete and kv:key delete inside kv.ts helpers.#980 202f37d Thanks @threepointone! - fix: throw appropriate error when we detect an unsupported version of node
When we start up the CLI, we check what the minimum version of supported node is, and throw an error if it isn't at least 16.7. However, the script that runs this, imports node:child_process and node:path, which was only introduced in 16.7. It was backported to older versions of node, but only in last updates to majors. So for example, if someone used 14.15.4, the script would throw because it wouldn't be able to find node:child_process (but it would work on v14.19.2).
The fix here is to not use the prefixed versions of these built-ins in the bootstrap script. Fixes https://github.com/cloudflare/workers-sdk/issues/979
#956 1caa5f7 Thanks @threepointone! - fix: don't crash during init if git is not installed
When a command isn't available on a system, calling execa() on it throws an error, and not just a non zero exitCode. This patch fixes the flow so we don't crash the whole process when that happens on testing the presence of git when calling wrangler init.
Fixes https://github.com/cloudflare/workers-sdk/issues/950
#970 35e780b Thanks @GregBrimble! - fix: Fixes Pages Plugins and static asset routing.
There was previously a bug where a relative pathname would be missing the leading slash which would result in routing errors.
#957 e0a0509 Thanks @JacobMGEvans! - refactor: Moving --legacy-env out of global
The --legacy-env flag was in global scope, which only certain commands
utilize the flag for functionality, and doesnt do anything for the other commands.
resolves #933
#948 82165c5 Thanks @petebacondarwin! - fix: improve error message if custom build output is not found
The message you get if Wrangler cannot find the output from the custom build is now more helpful.
It will even look around to see if there is a suitable file nearby and make suggestions about what should be put in the main configuration.
Closes #946
#952 ae3895e Thanks @d3lm! - feat: use host specific callback url
To allow OAuth to work on environments such as WebContainer we have to generate a host-specific callback URL. This PR uses @webcontainer/env to generate such URL only for running in WebContainer. Otherwise the callback URL stays unmodified.
#951 09196ec Thanks @petebacondarwin! - fix: look for an alternate port in the dev command if the configured one is in use
Previously, we were only calling getPort() if the configured port was undefined.
But since we were setting the default for this during validation, it was never undefined.
Fixes #949
#963 5b03eb8 Thanks @threepointone! - fix: work with Cloudflare WARP
Using wrangler with Cloudflare WARP (https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/) requires using the Cloudflare certificate. This patch simply uses the certificate as NODE_EXTRA_CA_CERTS when we start wrangler.
Test plan:
wrangler devwrangler devwrangler devFixes https://github.com/cloudflare/workers-sdk/issues/953, https://github.com/cloudflare/workers-sdk/issues/850
#964 0dfd95f Thanks @JacobMGEvans! - fix: KV not setting correctly
The KV has URL inputs, which in the case of / would get collapsed and lost.
T:o handle special characters encodeURIComponent is implemented.
resolves #961
38b7242 Thanks @GregBrimble! - Updated defaults and help of wrangler pages publish#941 d84b568 Thanks @threepointone! - fix: bundle worker as iife if detected as a service worker
We detect whether a worker is a "modules" format worker by the presence of a default export. This is a pretty good heuristic overall, but sometimes folks can make mistakes. One situation that's popped up a few times, is people writing exports, but still writing it in "service worker" format. We detect this fine, and log a warning about the exports, but send it up with the exports included. Unfortunately, our runtime throws when we mark a worker as a service worker, but still has exports. This patch fixes it so that the exports are not included in a service-worker worker.
Note that if you're missing an event listener, it'll still error with "No event handlers were registered. This script does nothing." but that's a better error than the SyntaxError even when the listener was there.
Fixes https://github.com/cloudflare/workers-sdk/issues/937
#932 e95e5a0 Thanks @threepointone! - fix: log proper response status codes in dev
During dev we log the method/url/statuscode for every req+res. This fix logs the correct details for every request.
Fixes https://github.com/cloudflare/workers-sdk/issues/931
bc28bea Thanks @GregBrimble! - fix: Default to creating a new project when no existing ones are available for 'wrangler pages publish'692ddc4 Thanks @GregBrimble! - fix: Suppress beta warning when operating in Pages' CI environment#936 a0e0b26 Thanks @petebacondarwin! - fix: support Windows line-endings in TOML files
The TOML parser that Wrangler uses crashes if there is a Windows line-ending in a comment. See https://github.com/iarna/iarna-toml/issues/33.
According to the TOML spec, we should be able to normalize line-endings as we see fit. See https://toml.io/en/v1.0.0#:~:text=normalize%20newline%20to%20whatever%20makes%20sense.
This change normalizes line-endings of TOML strings before parsing to avoid hitting this bug.
Fixes https://github.com/cloudflare/workers-sdk/issues/915
#928 7672f99 Thanks @threepointone! - ⛅️ Wrangler 2.0.0
Wrangler 2.0 is a full rewrite. Every feature has been improved, while retaining as much backward compatibility as we could. We hope you love it. It'll only get better.
#926 7b38a7c Thanks @threepointone! - polish: show paths of created files with wrangler init
This patch modifies the terminal when running wrangler init, to show the proper paths of files created during it (like package.json, tsconfig.json, etc etc). It also fixes a bug where we weren't detecting the existence of src/index.js for a named worker before asking to create it.
#924 3bdba63 Thanks @threepointone! - fix: withwrangler init, test for existence of package.json/ tsconfig.json / .git in the right locations
When running wrangler.init, we look for the existence of package.json, / tsconfig.json / .git when deciding whether we should create them ourselves or not. Because name can be a relative path, we had a bug where we don't starting look from the right directory. We also had a bug where we weren't even testing for the existence of the .git directory correctly. This patch fixes that initial starting location, tests for .git as a directory, and correctly decides when to create those files.
#922 e2f9bb2 Thanks @threepointone! - feat: offer to create a git repo when calling wrangler init
Worker projects created by wrangler init should also be managed by source control (popularly, git). This patch adds a choice in wrangler init to make the created project into a git repository.
Additionally, this fixes a bug in our tests where mocked confirm() and prompt() calls were leaking between tests.
Closes https://github.com/cloudflare/workers-sdk/issues/847
#916 4ef5fbb Thanks @petebacondarwin! - fix: display and error and help for wrangler init --site
The --site option is no longer supported.
This change adds information about how to create a new Sites project
by cloning a repository.
It also adds links to the Worker Sites and Cloudflare Pages docs.
#908 f8dd31e Thanks @threepointone! - fix: fix isolate prewarm logic for wrangler dev
When calling wrangler dev, we make a request to a special URL that "prewarms" the isolate running our Worker so that we can attach devtools etc to it before actually making a request. We'd implemented it wrongly, and because we'd silenced its errors, we weren't catching it. This patch fixes the logic (based on Wrangler v1.x's implementation) and enables logging errors when the prewarm request fails.
As a result, profiling starts working again as expected. Fixes https://github.com/cloudflare/workers-sdk/issues/907
#919 13078e1 Thanks @threepointone! - fix: don't crash when tail event is null
Sometime the "event" on a tail can be null. This patch makes sure we don't crash when that happens. Fixes https://github.com/cloudflare/workers-sdk/issues/918
#913 dfeed74 Thanks @threepointone! - polish: add a deprecation warning to --inspect on dev
We have a blogposts and docs that says you need to pass --inspect to use devtools and/or profile your Worker. In wrangler v2, we don't need to pass the flag anymore. Using it right now will throw an error, so this patch makes it a simple warning instead.
4ef5fbb Thanks @petebacondarwin! - fix: add some space after the CLI help message when there is an error#920 57cf221 Thanks @threepointone! - chore: don't minify bundles
When errors in wrangler happen, it's hard to tell where the error is coming from in a minified bundle. This patch removes the minification. We still set process.env.NODE_ENV = 'production' in the bundle so we don't run dev-only paths in things like React.
This adds about 2 mb to the bundle, but imo it's worth it.
4ef5fbb Thanks @petebacondarwin! - fix: update the generate command to provide better deprecation messaging9903526 Thanks @sidharthachatterjee! - fix: Ensure getting git branch doesn't fail on Windows94d3d6d Thanks @GregBrimble! - fix: Hit correct endpoint for 'wrangler pages publish'#910 fe0344d Thanks @taylorlee! - fix: support preview buckets for r2 bindings
Allows wrangler2 to perform preview & dev sessions with a different bucket than the published worker's binding.
This matches kv's preview_id behavior, and brings the Wrangler v2 implementation in sync with Wrangler v1.
#902 daed3c3 Thanks @petebacondarwin! - fix: show error if a string option is used without a value
Fixes #883
#901 b246066 Thanks @threepointone! - chore: minify bundle, don't ship sourcemaps
We haven't found much use for sourcemaps in production, and we should probably minify the bundle anyway. This will also remove an dev only warnings react used to log.
#904 641cdad Thanks @GregBrimble! - feat: Adds 'assets:' loader for Pages Functions.
This lets users and Plugin authors include a folder of static assets in Pages Functions.
export { onRequest } from "assets:../folder/of/static/assets";
More information in our docs.
c57ff0e Thanks @JacobMGEvans! - chore: removed Sentry and related reporting code. Automated reporting of Wrangler errors will be reimplemented after further planning.#897 d0801b7 Thanks @threepointone! - polish: tweak the message when .dev.vars is used
This tweaks the mssage when a .dev.vars file is used so that it doesn't imply that the user has to copy the values from it into their wrangler.toml.
#880 aad1418 Thanks @GregBrimble! - fix: Stop unnecessarily amalgamating duplicate headers in Pages Functions
Previously, set-cookie multiple headers would be combined because of unexpected behavior in the spec.
b08676a Thanks @GregBrimble! - fix: Adds the leading slash to Pages deployment manifests that the API expects, and fixes manifest generation on Windows machines.#852 6283ad5 Thanks @JacobMGEvans! - feat: non-TTY check for required variables
Added a check in non-TTY environments for account_id, CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN. If account_id exists in wrangler.toml
then CLOUDFLARE_ACCOUNT_ID is not needed in non-TTY scope. The CLOUDFLARE_API_TOKEN is necessary in non-TTY scope and will always error if missing.
resolves #827
#893 5bf17ca Thanks @petebacondarwin! - fix: remove bold font from additional lines of warnings and errors
Previously, when a warning or error was logged, the entire message was formatted in bold font. This change makes only the first line of the message bold, and the rest is formatted with a normal font.
#894 57c1354 Thanks @threepointone! - polish: s/DO NOT USE THIS/ Ignored
Followup to https://github.com/cloudflare/workers-sdk/pull/888, this replaces some more scary capitals with a more chill word.
5bf17ca Thanks @petebacondarwin! - fix: add bold to the Deprecated warning title#882 1ad7570 Thanks @petebacondarwin! - feat: add support for reading build time env variables from a .env file
This change will automatically load up a .env file, if found, and apply its
values to the current environment. An example would be to provide a specific
CLOUDFLARE_ACCOUNT_ID value.
Related to cloudflare#190
#887 2bb4d30 Thanks @threepointone! - polish: accept Enter as a valid key in confirm dialogs
Instead of logging "Unrecognised input" when hitting return/enter in a confirm dialog, we should accept it as a confirmation. This patch also makes the default choice "y" bold in the dialog.
#891 bae5ba4 Thanks @GregBrimble! - feat: Adds interactive prompts for the 'wrangler pages publish' and related commands.
Additionally, those commands now read from node_modules/.cache/wrangler/pages.json to persist users' account IDs and project names.
#888 b77aa38 Thanks @threepointone! - polish: s/DEPRECATION/Deprecation
This removes the scary uppercase from DEPRECATION warnings. It also moves the service environment usage warning into diagnostics instead of logging it directly.
#879 f694313 Thanks @petebacondarwin! - feat: read vars overrides from a local file for wrangler dev
The vars bindings can be specified in the wrangler.toml configuration file.
But "secret" vars are usually only provided at the server -
either by creating them in the Dashboard UI, or using the wrangler secret command.
It is useful during development, to provide these types of variable locally.
When running wrangler dev we will look for a file called .dev.vars, situated
next to the wrangler.toml file (or in the current working directory if there is no
wrangler.toml). Any values in this file, formatted like a dotenv file, will add to
or override vars bindings provided in the wrangler.toml.
Related to #190
#843 da12cc5 Thanks @threepointone! - fix: site.entry-point is no longer a hard deprecation
To make migration of v1 projects easier, Sites projects should still work, including the entry-point field (which currently errors out). This enables site.entry-point as a valid entry point, with a deprecation warning.
#848 0a79d75 Thanks @petebacondarwin! - polish: improve consistency of warnings and errors
Related to #377
#877 97f945f Thanks @caass! - Treat the "name" parameter in wrangler init as a path.
This means that running wrangler init . will create a worker in the current directory,
and the worker's name will be the name of the current directory.
You can also run wrangler init path/to/my-worker and a worker will be created at
[CWD]/path/to/my-worker with the name my-worker,
#851 277b254 Thanks @threepointone! - polish: do not log the error object when refreshing a token fails
We handle the error anyway (by doing a fresh login) which has its own logging and messaging. In the future we should add a DEBUG mode that logs all requests/errors/warnings, but that's for later.
#869 f1423bf Thanks @threepointone! - feat: experimental --node-compat / config.node_compat
This adds an experimental node.js compatibility mode. It can be enabled by adding node_compat = true in wrangler.toml, or by passing --node-compat as a command line arg for dev/publish commands. This is currently powered by @esbuild-plugins/node-globals-polyfill (which in itself is powered by rollup-plugin-node-polyfills).
We'd previously added this, and then removed it because the quality of the polyfills isn't great. We're reintroducing it regardless so we can start getting feedback on its usage, and it sets up a foundation for replacing it with our own, hopefully better maintained polyfills.
Of particular note, this means that what we promised in https://blog.cloudflare.com/announcing-stripe-support-in-workers/ now actually works.
This patch also addresses some dependency issues, specifically leftover entries in package-lock.json.
331c659 Thanks @sidharthachatterjee! - feature: Adds 'wrangler pages publish' (alias 'wrangler pages deployment create') command.#866 8b227fc Thanks @caass! - Add a runtime check for wrangler dev local mode to avoid erroring in environments with no AsyncLocalStorage class
Certain runtime APIs are only available to workers during the "request context", which is any code that returns after receiving a request and before returning a response.
Miniflare emulates this behavior by using an AsyncLocalStorage and
checking at runtime
to see if you're using those APIs during the request context.
In certain environments AsyncLocalStorage is unavailable, such as in a
webcontainer.
This function figures out if we're able to run those "request context" checks
and returns a set of options
that indicate to miniflare whether to run the checks or not.
#829 f08aac5 Thanks @JacobMGEvans! - feat: Add validation to the name field in configuration.
The validation will warn users that the field can only be "type string,
alphanumeric, underscores, and lowercase with dashes only" using the same RegEx as the backend
resolves #795 #775
#868 6ecb1c1 Thanks @threepointone! - feat: implement service environments + durable objects
Now that the APIs for getting migrations tags of services works as expected, this lands support for publishing durable objects to service environments, including migrations. It also removes the error we used to throw when attempting to use service envs + durable objects.
Fixes https://github.com/cloudflare/workers-sdk/issues/739
#838 9c025c4 Thanks @threepointone! - fix: remove timeout on custom builds, and make sure logs are visible
This removes the timeout we have for custom builds. We shouldn't be applying this timeout anyway, since it doesn't block wrangler, just the user themselves. Further, in https://github.com/cloudflare/workers-sdk/pull/759, we changed the custom build's process stdout/stderr config to "pipe" to pass tests, however that meant we wouldn't see logs in the terminal anymore. This patch removes the timeout, and brings back proper logging for custom builds.
9d04a68 Thanks @GregBrimble! - chore: rename --script-path to --outfile for wrangler pages functions build command.#836 28e3b17 Thanks @threepointone! - fix: toggle workers.dev subdomains only when required
This fix -
The effect of this is that publishes are much faster.
#794 ee3475f Thanks @JacobMGEvans! - fix: Error messaging from failed login would dump a JSON.parse error in some situations. Added a fallback if .json fails to parse
it will attempt .text() then throw result. If both attempts to parse fail it will throw an UnknownError with a message showing where
it originated.
resolves #539
#840 32f6108 Thanks @threepointone! - fix: make wrangler work on node v18
There's some interference between our data fetching library undici and node 18's new fetch and co. (powered by undici internally) which replaces the filename of Files attached to FormDatas with a generic blob (likely this code - https://github.com/nodejs/undici/blob/615f6170f4bd39630224c038d1ea5bf505d292af/lib/fetch/formdata.js#L246-L250). It's still not clear why it does so, and it's hard to make an isolated example of this.
Regardless, disabling the new fetch functionality makes undici use its own base classes, avoiding the problem for now, and unblocking our release. We'll keep investigating and look for a proper fix.
Unblocks https://github.com/cloudflare/workers-sdk/issues/834
#824 62af4b6 Thanks @threepointone! - feat: publish --dry-run
It can be useful to do a dry run of publishing. Developers want peace of mind that a project will compile before actually publishing to live servers. Combined with --outdir, this is also useful for testing the output of publish. Further, it gives developers a chance to upload our generated sourcemap to a service like sentry etc, so that errors from the worker can be mapped against actual source code, but before the service actually goes live.
feecc18 Thanks @GregBrimble! - fix: Allows next() to take just a pathname with Pages Functions.#839 f2d6de6 Thanks @threepointone! - fix: persist dev experimental storage state in feature specific dirs
With --experimental-enable-local-persistence in dev, we were clobbering a single folder with data from kv/do/cache. This patch gives individual folders for them. It also enables persistence even when this is not true, but that stays only for the length of a session, and cleans itself up when the dev session ends.
Fixes https://github.com/cloudflare/workers-sdk/issues/830
#820 60c409a Thanks @petebacondarwin! - fix: display a warning if the user has a miniflare section in their wrangler.toml.
Closes #799
3e0db3b Thanks @GregBrimble! - fix: Makes Response Headers object mutable after a call to next() in Pages Functions#814 51fea7c Thanks @threepointone! - fix: disallow setting account_id in named service environments
Much like https://github.com/cloudflare/workers-sdk/pull/641, we don't want to allow setting account_id with named service environments. This is so that we use the same account_id for multiple environments, and have them group together in the dashboard.
#823 4a00910 Thanks @threepointone! - fix: don't log an error when wrangler dev is cancelled early
We currently log an AbortError with a stack if we exit wrangler dev's startup process before it's done. This fix skips logging that error (since it's not an exception).
Test plan:
cd packages/wrangler
npm run build
cd ../../examples/workers-chat-demo
npx wrangler dev
# hit [x] as soon as the hotkey shortcut bar shows
#815 025c722 Thanks @threepointone! - fix: ensure that bundle is generated to es2020 target
The default tsconfig generated by tsc uses target: "es5", which we don't support. This fix ensures that we output es2020 modules, even if tsconfig asks otherwise.
9d04a68 Thanks @GregBrimble! - feature: Adds a --plugin option to wrangler pages functions build which compiles a Pages Plugin. More information about Pages Plugins can be found here. This wrangler build is required for both the development of, and inclusion of, plugins.4302172 Thanks @GregBrimble! - chore: Add help messages for wrangler pages project and wrangler pages deployment#837 206b9a5 Thanks @threepointone! - polish: replace 🦺 with ⚠️
I got some feedback that the construction worker jacket (?) icon for deprecations is confusing, especially because it's an uncommon icon and not very big in the terminal. This patch replaces it with a more familiar warning symbol.
#824 62af4b6 Thanks @threepointone! - feat: publish --outdir <path>
It can be useful to introspect built assets. A leading usecase is to upload the sourcemap that we generate to services like sentry etc, so that errors from the worker can be mapped against actual source code. We introduce a --outdir cli arg to specify a path to generate built assets at, which doesn't get cleaned up after publishing. We are not adding this to wrangler.toml just yet, but could in the future if it looks appropriate there.
#811 8c2c7b7 Thanks @JacobMGEvans! - feat: Added minify as a configuration option and a cli arg, which will minify code for dev and publish
resolves #785
#782 34552d9 Thanks @GregBrimble! - feature: Add 'pages create project [name]' command.
This command will create a Pages project with a given name, and optionally set its --production-branch=[production].
a852e32 Thanks @JacobMGEvans! - fix: We want to prevent any user created code from sending Events to Sentry,
which can be captured by uncaughtExceptionMonitor listener.
Miniflare code can run user code on the same process as Wrangler,
so we want to return null if @miniflare is present in the Event frames.#778 85b0c31 Thanks @threepointone! - feat: optionally send zone_id with a route
This enables optionally passing a route as {pattern: string, zone_id: string}. There are scenarios where we need to explicitly pass a zone_id to the api, so this enables that.
Some nuance: The errors from the api aren't super useful when invalid values are passed, but that's something to further work on.
This also fixes some types in our cli parsing.
Fixes https://github.com/cloudflare/workers-sdk/issues/774
#797 67fc4fc Thanks @threepointone! - feat: optionally send zone_name with routes
A followup to https://github.com/cloudflare/workers-sdk/pull/778, this lets you send an optional zone_name with routes. This is particularly useful when using ssl for saas (https://developers.cloudflare.com/ssl/ssl-for-saas/).
Fixes https://github.com/cloudflare/workers-sdk/issues/793
#813 5c59f97 Thanks @threepointone! - add a warning if service environments are being used.
Service environments are not ready for widespread usage, and their behaviour is going to change. This adds a warning if anyone uses them.
Closes https://github.com/cloudflare/workers-sdk/issues/809
#789 5852bba Thanks @threepointone! - polish: don't log all errors when logging in
This removes a couple of logs we had for literally every error in our oauth flow. We throw the error and handle it separately anyway, so this is a safe cleanup.
Fixes https://github.com/cloudflare/workers-sdk/issues/788
#806 b24aeb5 Thanks @threepointone! - fix: check for updates on the right channel
This makes the update checker run on the channel that the version being used runs on.
#807 7e560e1 Thanks @threepointone! - fix: read isLegacyEnv correctly
This fixes the signature for isLegacyEnv() since it doesn't use args, and we fix reading legacy_env correctly when creating a draft worker when creating a secret.
#779 664803e Thanks @threepointone! - chore: update packages
This updates some dependencies. Some highlights -
@iarna/toml means we can have mixed types for inline arrays, which is great for #774 / https://github.com/cloudflare/workers-sdk/pull/778devDependencies since it already gets compiled into the bundleesbuild brings along a number of smaller fixes for modern js#810 0ce47a5 Thanks @caass! - Make wrangler tail TTY-aware, and stop printing non-JSON in JSON mode
Closes #493
2 quick fixes:
process.stdout.isTTY at runtime to determine whether to default to "pretty" or "json" output for tailing.#752 6d43e94 Thanks @petebacondarwin! - fix: add a warning if dev is defaulting to the latest compatibility-date
Fixes https://github.com/cloudflare/workers-sdk/issues/741
#767 836ad59 Thanks @threepointone! - fix: use cwd for --experiment-enable-local-persistence
This sets up --experiment-enable-local-persistence to explicitly use process.cwd() + wrangler-local-state as a path to store values. Without it, local mode uses the temp dir that we use to bundle the worker, which gets wiped out on ending wrangler dev. In the future, based on usage, we may want to make the path configurable as well.
Fixes https://github.com/cloudflare/workers-sdk/issues/766
#723 7942936 Thanks @threepointone! - fix: spread tail messages when logging
Logged messages (via console, etc) would previously be logged as an array of values. This spreads it when logging to match what is expected.
#756 8e38442 Thanks @threepointone! - fix: resolve raw file bindings correctly in wrangler dev local mode
For wasm_modules/text_blobs/data_blobs in local mode, we need to rewrite the paths as absolute so that they're resolved correctly by miniflare. This also expands some coverage for local mode wrangler dev.
Fixes https://github.com/cloudflare/workers-sdk/issues/740 Fixes https://github.com/cloudflare/workers-sdk/issues/416
ea8e701 Thanks @JacobMGEvans! - polish: added logout and login to helpstring message.#728 0873049 Thanks @threepointone! - fix: only send durable object migrations when required
We had a bug where even if you'd published a script with migrations, we would still send a blank set of migrations on the next round. The api doesn't accept this, so the fix is to not do so. I also expanded test coverage for migrations.
Fixes https://github.com/cloudflare/workers-sdk/issues/705
#763 f72c943 Thanks @JacobMGEvans! - feat: Added the update check that will check the package once a day against the beta release, distTag can be changed later, then prints the latestbeta version to the user.
resolves #762
#695 48fa89b Thanks @caass! - fix: stop wrangler spamming console after login
If a user hasn't logged in and then they run a command that needs a login they'll get bounced to the login flow. The login flow (if completed) would write their shiny new OAuth2 credentials to disk, but wouldn't reload the in-memory state. This led to issues like #693, where even though the user was logged in on-disk, wrangler wouldn't be aware of it.
We now update the in-memory login state each time new credentials are written to disk.
#734 a1dadac Thanks @threepointone! - fix: exit dev if build fails on first run
Because of https://github.com/evanw/esbuild/issues/1037, we can't recover dev if esbuild fails on first run. The workaround is to end the process if it does so, until we have a better fix.
Reported in https://github.com/cloudflare/workers-sdk/issues/731
#757 13e57cd Thanks @sidharthachatterjee! - feature: Add wrangler pages project list
Adds a new command to list your projects in Cloudflare Pages.
#745 6bc3e85 Thanks @petebacondarwin! - feat: add hotkey to clear the console in wrangler dev
Closes #388
#747 db6b830 Thanks @petebacondarwin! - refactor: remove process.exit() from the pages code
This enables simpler testing, as we do not have to spawn new child processes
to avoid the process.exit() from killing the jest process.
As part of the refactor, some of the Error classes have been moved to a
shared errors.ts file.
#726 c4e5dc3 Thanks @threepointone! - fix: assume a worker is a module worker only if it has a default export
This tweaks the logic that guesses worker formats to check whether a default export is defined on an entry point before assuming it's a module worker.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Updated dependencies [ 2f5781a ]:
2f5781a]:
Nothing published for this version
Updated dependencies [ a0485d5 ]:
a0485d5]:
Updated dependencies [ 2298cf1 , 876eea1 ]:
Updated dependencies [ 71b6f10 , ad23e6e , 6f3d7b5 ]:
a0485d5, c4c9b75, 643e5cc]:
Updated dependencies [ 7db596c , e35c4a1 , d3565a5 , ca71205 , 1015cfb , 982b806 , 641df47 ]:
6874aa9, 2298cf1, 876eea1, edb2fe7]:
Updated dependencies [ 8997652 ]:
8997652]:
Updated dependencies [ 47d906f , c2699bf ]:
74bf083, c103dd6, c103dd6, 7db596c, a83d7ac, e35c4a1, d3565a5, a83d7ac, cb0955f, fa79b26, 16d1310, ca71205, 1015cfb, 982b806, a83d7ac, 641df47, c4a6279]:
Updated dependencies [ f45b596 , f69f95a , a549e58 , dbb3ff4 , fea3cd0 , 6bd7b6c , 15cd6e1 , be1caec , dbc9506 ]:
8997652, 60d40f8]:
Updated dependencies [ edb3631 , bcebf08 ]:
Updated dependencies [ 0b43395 , f45b596 , f69f95a , a549e58 , 36aed7f , bff525d , dbb3ff4 , fea3cd0 , 6bd7b6c , 15cd6e1 , be1caec , dbc9506 ]:
Updated dependencies [ 00a9f2f , 1dba24a , d40a634 , 7c1b2a6 ]:
edb3631, bcebf08, a849e0d]:
Updated dependencies [ eb01850 , e1df91a , b23de74 , 015550a , 015550a , 015550a , 3650d29 , b23de74 ]:
Updated dependencies [ dbbb795 , 200780f , b3f2628 , 87a7acf , ea28cc3 ]:
Updated dependencies [ eb01850 , e1df91a , b23de74 , 015550a , 015550a , 015550a , 3650d29 , b23de74 ]:
Updated dependencies [ 59872c4 , 99a1f49 , 5ae9d5b , 4b52975 , ce9b151 , 99a1f49 , 99a1f49 , 30c2d47 ]:
Updated dependencies [ aa54b49 , 4a67a28 , 2d78137 , 04e8564 , 693ca29 , 693ca29 , 693ca29 , 37ed753 , f76b68e , c809851 , c66d2d5 , 693ca29 , 74de3ab
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →