Skip to content

Releases: cloudflare/workers-sdk

[email protected]

05 Jul 11:29
d529533
Compare
Choose a tag to compare

Patch Changes

  • #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 #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 #1300 as --no-build, renamed in #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 #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

  • #1342 6426625 Thanks @rozenmd! - polish: split dev function out of index.tsx

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

  • #1344 7ba19fe Thanks @rozenmd! - polish: move init into its own file

  • #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!"`);
      }
    
      await 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.

  • #1278 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 #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](https://github.com/cloudflare/wran...

Read more

[email protected]

22 Jun 15:06
bfbb0be
Compare
Choose a tag to compare

Patch Changes

  • #1301 9074990 Thanks @mrbbot! - Upgrade miniflare to 2.5.1

  • #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 #405 (comment))

  • #1287 2072e27 Thanks @f5io! - fix: kv:key put/get binary file

    As raised in #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 #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.

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

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

  • #1275 35482da Thanks @alankemp! - Add environment variable WRANGLER_LOG to set log level

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

[email protected]

22 Jun 15:06
bfbb0be
Compare
Choose a tag to compare

Patch Changes

[email protected]

17 Jun 06:05
2330c33
Compare
Choose a tag to compare

Patch Changes

[email protected]

14 Jun 14:46
e61fba8
Compare
Choose a tag to compare

Patch Changes

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

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

  • #1250 e3278fa Thanks @rozenmd! - fix: pass localProtocol to miniflare for https server

    Closes #1247

  • #1253 eee5c78 Thanks @threepointone! - fix: resolve asset handler for --experimental-path

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

    • all the source code isn't in one folder (like a monorepo, or even where the worker has non-standard imports across folders),
    • we use a custom build, so it's hard to statically determine folders to watch for changes

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

[email protected]

13 Jun 15:41
010e319
Compare
Choose a tag to compare

Patch Changes

  • #1239 df55709 Thanks @threepointone! - polish: don't include folder name in Sites kv asset keys

    As reported in #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 #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.

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

[email protected]

10 Jun 14:48
b917999
Compare
Choose a tag to compare

Patch Changes

  • #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 #1003
    Fixes #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 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 whoami

    Closes #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 git

    Rather than using the recently added --initial-branch option, we now just renamed the initial branch using git branch -m main.

    Fixes #1168

[email protected]

08 Jun 09:34
d7a48cb
Compare
Choose a tag to compare

Patch Changes

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

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

    Fixes #1136

  • #1166 08e3a49 Thanks @threepointone! - fix: warn on unexpected fields on migrations

    This adds a warning for unexpected fields on [migrations] config, reported in #1165. It also adds a test for incorrect renamed_classes in a migration.

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

[email protected]

27 May 14:23
900670b
Compare
Choose a tag to compare

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

    • 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 notably dev)
    • 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.
  • #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 1 did with wrangler build let's run that for the user if
    they try to run wrangler 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 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.

[email protected]

19 May 09:22
10b3925
Compare
Choose a tag to compare

Patch Changes