Releases: cloudflare/workers-sdk
wrangler@2.0.9
Patch Changes
-
#1192
bafa5ac
Thanks @threepointone! - fix: use worker name as a script ID when generating a preview sessionWhen 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. -
#1212
101342e
Thanks @petebacondarwin! - fix: do not crash when not logged in and switching to remote dev modePreviously, 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 auseEffect()
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()
andmockApiToken()
calls from thedev.test.ts
files.Fixes #18
-
#1188
b44cc26
Thanks @petebacondarwin! - fix: fallback on old zone-based API when account-based route API failsWhile 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 1 approach, which sends individual route updates via a zone-based
endpoint.Fixes #651
-
#1203
3b88b9f
Thanks @rozenmd! - fix: differentiate between API and OAuth in whoamiCloses #1198
-
#1199
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 gitRather than using the recently added
--initial-branch
option, we now just renamed the initial branch usinggit branch -m main
.Fixes #1168
wrangler@2.0.8
Patch Changes
-
#1184
4a10176
Thanks @timabb031! - polish: add cron trigger to wrangler.toml when new Scheduled Worker is createdWhen
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 runningwrangler 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 indev
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
andnode_compat
should be inheritedFixes #1150
- #1157
ea8f8d7
Thanks @sidharthachatterjee! - fix: Ignore .git when publishing a Pages project
-
#1171
de4e3c2
Thanks @petebacondarwin! - fix: link to the issue chooser in GitHubPreviously, when an error occurs, wrangler says:
If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/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 itWith 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 #1136.
Fixes #1136
-
#1166
08e3a49
Thanks @threepointone! - fix: warn on unexpected fields on migrationsThis adds a warning for unexpected fields on
[migrations]
config, reported in #1165. It also adds a test for incorrectrenamed_classes
in a migration.
- #1006
ee0c380
Thanks @danbulant! - feat: add pnpm support
6187f36
Thanks @petebacondarwin! - fix: backslash on manifest keys in windows
- #1158
e452a35
Thanks @sidharthachatterjee! - fix: Skip cfFetch if there are no functions during pages dev
-
#1122
c2d2f44
Thanks @petebacondarwin! - fix: display chained errors from the CF APIFor example if you have an invalid CF_API_TOKEN and try running
wrangler whoami
you now get the additional6111
error information:✘ [ERROR] A request to the Cloudflare API (/user) failed. Invalid request headers [code: 6003] - Invalid format for Authorization header [code: 6111]
- #1161
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 missingThis 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 #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 withwrangler 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 asemail
can be added easily in future.
- #1122
c2d2f44
Thanks @petebacondarwin! - fix: improve error message when CF API responds with an error
wrangler@2.0.7
Patch Changes
-
#1110
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 proxyConfigures 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 onceWhen 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 duringdev
andpublish
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
andwrangler publish
. -
#1097
c73a3c4
Thanks @petebacondarwin! - fix: ensure all line endings are normalized before parsing as TOMLOnly the last line-ending was being normalized not all of them.
Fixes #1094
-
#1111
1eaefeb
Thanks @JacobMGEvans! - Git defaultmain
branchpolish: 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 validationThis does a small refactor -
- During publish, we were checking whether
[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 notablydev
) - It moves the code to determine current migration tag/migrations to upload into a helper. We'll be reusing this soon when we upload migrations to
dev
.
- During publish, we were checking whether
-
#1090
85fbfe8
Thanks @petebacondarwin! - refactor: remove use ofany
This "quick-win" refactors some of the code to avoid the use of
any
where possible.
Usingany
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 preventwrangler dev
from hangingWhen 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 aHttpTerminator
helper library to force the proxy to close open connections and shutdown correctly.Fixes #958
-
#1099
175737f
Thanks @petebacondarwin! - fix: delegatewrangler build
towrangler publish
Since
wrangler publish --dry-run --outdir=dist
is basically the same result
as what Wrangler 1 did withwrangler build
let's run that for the user if
they try to runwrangler build
. -
#1081
8070763
Thanks @rozenmd! - fix: friendlier error for when a subdomain hasn't been configured in dev mode -
#1123
15e5c12
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 PairsCloses #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 inpages
will be it does not check thewrangler.toml
so thenode_compat = true
will not enable it forwrangler 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.
wranglerjs-compat-webpack-plugin@0.0.5
Patch Changes
8529678
Thanks @threepointone! - fix: build the webpack plugin along with the others
wrangler@2.0.6
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
wrangler@2.0.5
Patch Changes
556e6dd
Thanks @threepointone! - chore: bump to do a release
wrangler@2.0.3
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
wrangler@2.0.2
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
wrangler@2.0.1
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
wrangler@2.0.0
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.