Skip to content

Releases: cloudflare/workers-sdk

[email protected]

19 May 08:43
0d5a03f
Compare
Choose a tag to compare

Patch Changes

  • #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 #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

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 mode

    Fixes #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 #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

  • #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 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 #571

  • #1037 963e9e0 Thanks @rozenmd! - fix: don't attempt to login during a --dryRun

[email protected]

13 May 16:10
9906e1c
Compare
Choose a tag to compare

Patch Changes

[email protected]

12 May 08:19
ded19b1
Compare
Choose a tag to compare

Patch Changes

  • #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 #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:

    • Turn on Cloudflare WARP/ Gateway with WARP
    • wrangler dev
    • Turn on Cloudflare WARP/ Gateway with DoH
    • wrangler dev
    • Turn off Cloudflare WARP
    • wrangler dev

    Fixes #953, #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

[email protected]

10 May 09:44
1a7a7f1
Compare
Choose a tag to compare

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 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 #937

[email protected]

09 May 11:46
6834010
Compare
Choose a tag to compare

Patch Changes

[email protected]

08 May 20:26
68ddad5
Compare
Choose a tag to compare

Major Changes

  • #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.

[email protected]

08 May 16:20
893ed38
Compare
Choose a tag to compare

Patch Changes

  • #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.

[email protected]

08 May 13:54
18adf1a
Compare
Choose a tag to compare

Patch Changes

  • #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.

[email protected]

08 May 12:55
596d5b2
Compare
Choose a tag to compare

Patch Changes

  • #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 #847

[email protected]

07 May 21:41
f584ae6
Compare
Choose a tag to compare

Patch Changes

  • #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 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 null

    Sometime 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 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.

  • #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 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.

  • #916 4ef5fbb Thanks @petebacondarwin! - fix: update the generate 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 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 wrangler2 implementation in sync with wrangler1.