Releases: cloudflare/workers-sdk
[email protected]
Patch Changes
-
#1018
cd2c42f
Thanks @threepointone! - fix: strip leading*
/*.
from routes when deducing a host fordev
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 #1002
-
#1044
7a191a2
Thanks @JacobMGEvans! - fix: trim trailing whitespace from the secrets before uploadingresolves #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
3279f10
Thanks @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:
[[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 #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
modeFixes #1038
-
#1033
ffce3e3
Thanks @petebacondarwin! - fix:wrangler init
should not crash if Git is not available on WindowsWe check for the presence of Git by trying to run
git --version
.
On non-Windows we get an Error withcode
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 DomainsWith 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 environmentFor 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 #996
-
#1057
608dcd9
Thanks @petebacondarwin! - fix: pages "command" can consist of multiple wordsOn Windows, the following command
wrangler pages dev -- foo bar
would error
saying thatbar
was not a known argument. This is becausefoo
andbar
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 thecommand
argument variadic, which also solves the problem.Fixes #965
-
#1027
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 forkv:bulk put
on client sideThis 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 #571
-
#1037
963e9e0
Thanks @rozenmd! - fix: don't attempt to login during a --dryRun
[email protected]
Patch Changes
556e6dd
Thanks @threepointone! - chore: bump to do a release
[email protected]
Patch Changes
-
#956
1caa5f7
Thanks @threepointone! - fix: don't crash duringinit
ifgit
is not installedWhen 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 ofgit
when callingwrangler init
.Fixes #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 foundThe 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 themain
configuration.Closes #946
-
#952
ae3895e
Thanks @d3lm! - feat: use host specific callback urlTo 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 usePreviously, 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 WARPUsing 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:
- Turn on Cloudflare WARP/ Gateway with WARP
wrangler dev
- Turn on Cloudflare WARP/ Gateway with DoH
wrangler dev
- Turn off Cloudflare WARP
wrangler dev
-
#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 charactersencodeURIComponent
is implemented.resolves #961
[email protected]
Patch Changes
-
#947
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 workerWe 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 #937
[email protected]
Patch Changes
-
#932
e95e5a0
Thanks @threepointone! - fix: log proper response status codes indev
During
dev
we log the method/url/statuscode for every req+res. This fix logs the correct details for every request.Fixes #931
-
#930
bc28bea
Thanks @GregBrimble! - fix: Default to creating a new project when no existing ones are available for 'wrangler pages publish' -
#934
692ddc4
Thanks @GregBrimble! - fix: Suppress beta warning when operating in Pages' CI environment -
#936
a0e0b26
Thanks @petebacondarwin! - fix: support Windows line-endings in TOML filesThe TOML parser that Wrangler uses crashes if there is a Windows line-ending in a comment.
See iarna/iarna-toml#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 #915
[email protected]
Major Changes
-
#928
7672f99
Thanks @threepointone! - ⛅️ Wrangler 2.0.0Wrangler 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.
[email protected]
Patch Changes
-
#926
7b38a7c
Thanks @threepointone! - polish: show paths of created files withwrangler init
This patch modifies the terminal when running
wrangler init
, to show the proper paths of files created during it (likepackage.json
,tsconfig.json
, etc etc). It also fixes a bug where we weren't detecting the existence ofsrc/index.js
for a named worker before asking to create it.
[email protected]
Patch Changes
-
#924
3bdba63
Thanks @threepointone! - fix: withwrangler init
, test for existence ofpackage.json
/tsconfig.json
/.git
in the right locationsWhen running
wrangler.init
, we look for the existence ofpackage.json
, /tsconfig.json
/.git
when deciding whether we should create them ourselves or not. Becausename
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.
[email protected]
Patch Changes
-
#922
e2f9bb2
Thanks @threepointone! - feat: offer to create a git repo when callingwrangler init
Worker projects created by
wrangler init
should also be managed by source control (popularly, git). This patch adds a choice inwrangler init
to make the created project into a git repository.Additionally, this fixes a bug in our tests where mocked
confirm()
andprompt()
calls were leaking between tests.Closes #847
[email protected]
Patch Changes
-
#916
4ef5fbb
Thanks @petebacondarwin! - fix: display and error and help forwrangler 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 forwrangler 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 1.x's implementation) and enables logging errors when the prewarm request fails.As a result, profiling starts working again as expected. Fixes #907
-
#919
13078e1
Thanks @threepointone! - fix: don't crash when tail event is nullSometime the "event" on a tail can be null. This patch makes sure we don't crash when that happens. Fixes #918
-
#913
dfeed74
Thanks @threepointone! - polish: add a deprecation warning to--inspect
ondev
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. -
#916
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 bundlesWhen 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.
-
#916
4ef5fbb
Thanks @petebacondarwin! - fix: update thegenerate
command to provide better deprecation messaging -
#914
9903526
Thanks @sidharthachatterjee! - fix: Ensure getting git branch doesn't fail on Windows -
#917
94d3d6d
Thanks @GregBrimble! - fix: Hit correct endpoint for 'wrangler pages publish' -
#910
fe0344d
Thanks @taylorlee! - fix: support preview buckets for r2 bindingsAllows 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 wrangler2 implementation in sync with wrangler1.