Skip to content

Releases: cloudflare/workers-sdk

[email protected]

22 Feb 18:20
99508bf
Compare
Choose a tag to compare

Patch Changes

  • #5066 ef064279 Thanks @dependabot! - chore: Bumped create-remix from 2.6.0 to 2.7.1

  • #5052 f68e83e2 Thanks @jculvey! - feature: Add script to Qwik template for building Env type definitions.

    When creating a project with the Qwik template, the QwikCityPlatform type will be updated to contain a definition for the env property. These types can be re-generated with a newly added build-cf-types script.

@cloudflare/[email protected]

22 Feb 18:20
99508bf
Compare
Choose a tag to compare

Patch Changes

[email protected]

20 Feb 17:05
d0fb7b8
Compare
Choose a tag to compare

Patch Changes

  • #5050 88be4b84 Thanks @nora-soderlund! - fix: allow kv:namespace create to accept a namespace name that contains characters not allowed in a binding name

    This command tries to use the namespace name as the binding. Previously, we would unnecessarily error if this namespace name did not fit the binding name constraints. Now we accept such names and then remove invalid characters when generating the binding name.

[email protected]

16 Feb 21:11
fd0fb23
Compare
Choose a tag to compare

Patch Changes

  • #5026 04584722 Thanks @dario-piotrowicz! - fix: make sure getPlatformProxy produces a production-like caches object

    make sure that the caches object returned to getPlatformProxy behaves
    in the same manner as the one present in production (where calling unsupported
    methods throws a helpful error message)

    note: make sure that the unsupported methods are however not included in the
    CacheStorage type definition

  • #5030 55ea0721 Thanks @mrbbot! - fix: don't suggest reporting user errors to GitHub

    Wrangler has two different types of errors: internal errors caused by something going wrong, and user errors caused by an invalid configuration. Previously, we would encourage users to submit bug reports for user errors, even though there's nothing we can do to fix them. This change ensures we only suggest this for internal errors.

  • #4900 3389f2e9 Thanks @OilyLime! - feature: allow hyperdrive users to set local connection string as environment variable

    Wrangler dev now supports the HYPERDRIVE_LOCAL_CONNECTION_STRING environmental variable for connecting to a local database instance when testing Hyperdrive in local development. This environmental variable takes precedence over the localConnectionString set in wrangler.toml.

  • #5033 b1ace91b Thanks @mrbbot! - fix: wait for actual port before opening browser with --port=0

    Previously, running wrangler dev --remote --port=0 and then immediately pressing b would open localhost:0 in your default browser. This change queues up opening the browser until Wrangler knows the port the dev server was started on.

  • #5026 04584722 Thanks @dario-piotrowicz! - fix: relax the getPlatformProxy's' cache request/response types

    prior to these changes the caches obtained from getPlatformProxy
    would use unknowns as their types, this proved too restrictive
    and incompatible with the equivalent @cloudflare/workers-types
    types, we decided to use anys instead to allow for more flexibility
    whilst also making the type compatible with workers-types

  • Updated dependencies [7723ac17, 027f9719, 027f9719, 027f9719, 027f9719, 027f9719, 027f9719]:

[email protected]

16 Feb 21:11
fd0fb23
Compare
Choose a tag to compare

Minor Changes

  • #4795 027f9719 Thanks @mrbbot! - feat: pass Miniflare instance as argument to custom service binding handlers

    This change adds a new Miniflare-typed parameter to function-valued service binding handlers. This provides easy access to the correct bindings when re-using service functions across instances.

    import assert from "node:assert";
    import { Miniflare, Response } from "miniflare";
    
    const mf = new Miniflare({
    	serviceBindings: {
    		SERVICE(request, instance) {
    			assert(instance === mf);
    			return new Response();
    		},
    	},
    });
  • #4795 027f9719 Thanks @mrbbot! - feat: allow URLs to be passed in hyperdrives

    Previously, the hyperdrives option only accepted strings as connection strings. This change allows URL objects to be passed too.

  • #4795 027f9719 Thanks @mrbbot! - feat: add support for custom root paths

    Miniflare has lots of file-path-valued options (e.g. scriptPath, kvPersist, textBlobBindings). Previously, these were always resolved relative to the current working directory before being used. This change adds a new rootPath shared, and per-worker option for customising this behaviour. Instead of resolving relative to the current working directory, Miniflare will now resolve path-valued options relative to the closest rootPath option. Paths are still resolved relative to the current working directory if no rootPaths are defined. Worker-level rootPaths are themselves resolved relative to the shared rootPath if defined.

    import { Miniflare } from "miniflare";
    
    const mf1 = new Miniflare({
    	scriptPath: "index.mjs",
    });
    
    const mf2 = new Miniflare({
    	rootPath: "a/b",
    	scriptPath: "c/index.mjs",
    });
    
    const mf3 = new Miniflare({
    	rootPath: "/a/b",
    	workers: [
    		{
    			name: "1",
    			rootPath: "c",
    			scriptPath: "index.mjs",
    		},
    		{
    			name: "2",
    			scriptPath: "index.mjs",
    		},
    	],
    });
  • #4795 027f9719 Thanks @mrbbot! - feat: allow easy binding to current worker

    Previously, if you wanted to create a service binding to the current Worker, you'd need to know the Worker's name. This is usually possible, but can get tricky when dealing with many Workers. This change adds a new kCurrentWorker symbol that can be used instead of a Worker name in serviceBindings. kCurrentWorker always points to the Worker with the binding.

    import { kCurrentWorker, Miniflare } from "miniflare";
    
    const mf = new Miniflare({
    	serviceBindings: {
    		SELF: kCurrentWorker,
    	},
    	modules: true,
    	script: `export default {
        fetch(request, env, ctx) {
          const { pathname } = new URL(request.url);
          if (pathname === "/recurse") {
            return env.SELF.fetch("http://placeholder");
          }
          return new Response("body");
        }
      }`,
    });
    
    const response = await mf.dispatchFetch("http://placeholder/recurse");
    console.log(await response.text()); // body

Patch Changes

  • #4954 7723ac17 Thanks @mrbbot! - fix: allow relative scriptPath/modulesRoots to break out of current working directory

    Previously, Miniflare would resolve relative scriptPaths against moduleRoot multiple times resulting in incorrect paths and module names. This would lead to can't use ".." to break out of starting directory workerd errors. This change ensures Miniflare uses scriptPath as is, and only resolves it relative to modulesRoot when computing module names. Note this bug didn't affect service workers. This allows you to reference a modules scriptPath outside the working directory with something like:

    const mf = new Miniflare({
    	modules: true,
    	modulesRoot: "..",
    	scriptPath: "../worker.mjs",
    });

    Fixes #4721

  • #4795 027f9719 Thanks @mrbbot! - fix: return non-WebSocket responses for failed WebSocket upgrading fetch()es

    Previously, Miniflare's fetch() would throw an error if the Upgrade: websocket header was set, and a non-WebSocket response was returned from the origin. This change ensures the non-WebSocket response is returned from fetch() instead, with webSocket set to null. This allows the caller to handle the response as they see fit.

  • #4795 027f9719 Thanks @mrbbot! - fix: ensure MiniflareOptions, WorkerOptions, and SharedOptions types are correct

    Miniflare uses Zod for validating options. Previously, Miniflare inferred *Options from the output types of its Zod schemas, rather than the input types. In most cases, these were the same. However, the hyperdrives option has different input/output types, preventing these from being type checked correctly.

[email protected]

16 Feb 21:11
fd0fb23
Compare
Choose a tag to compare

Minor Changes

  • #4996 246512c8 Thanks @jculvey! - feature: Add getBindingsProxy support to nuxt template via nitro-cloudflare-dev module.

    The nuxt template now uses the default dev command from create-nuxt instead of using wrangler pages dev on build output in order to improve the developer workflow. nitro-cloudflare-dev is a nitro module that leverages getBindingsProxy and allows bindings to work in nitro commands.

  • #5027 a751489f Thanks @jculvey! - feature: Improve bindings support in Svelte template.

    C3 will now create Svelte projects with a hook that uses getPlatformProxy to proxy bindings in development mode. A wrangler.toml file will also be added where bindings can be added to be used in conjunction with getPlatformProxy.

    Along with this change, projects will use the default vite-based dev command from create-svelte instead of using wrangler pages dev on build output.

    When Typescript is used, the app.d.ts will be updated to add type definitions for cf and ctx to the Platform interface from the @cloudflare/workers-types package. Types for bindings on platform.env can be re-generated with a newly added build-cf-types script.

Patch Changes

  • #5001 efe8b444 Thanks @dependabot! - chore: Bumped create-hono from 0.3.2 to 0.4.0

  • #5011 89482d44 Thanks @dependabot! - chore: Bumped create-qwik from 1.4.4 to 1.4.5

  • #5019 f939ed73 Thanks @dependabot! - chore: Bumped @angular/create from 17.1.3 to 17.2.0

  • #5020 0e74c743 Thanks @dependabot! - chore: Bumped nuxi from 3.10.0 to 3.10.1

  • #5021 ae1ef47c Thanks @dependabot! - chore: Bumped create-astro from 4.7.2 to 4.7.3

  • #5009 1e263694 Thanks @dario-piotrowicz! - chore: update Next.js template

    Update the C3 Next.js template so that it uses the latest @cloudflare/next-on-pages tooling (i.e. setupDevPlatform and getRequestContext)

  • #4996 246512c8 Thanks @jculvey! - feature: Add an empty wrangler.toml file to qwik and nuxt templates.

  • #4999 ce6d4bc4 Thanks @dario-piotrowicz! - fix: make sure not to wrongly ask users if they want to use typescript

    currently if a CLI invoked by C3 asks the user if they want to use
    typescript and the user opted out of it, C3 could actually again offer
    typescript to the user afterwords, make sure that this does not happen

  • #5010 9f787042 Thanks @dario-piotrowicz! - chore: update qwik template to use getPlatformProxy

    update the C3 Qwik template to use the getPlatformProxy utility instead of the deprecated getBindingsProxy one

@cloudflare/[email protected]

16 Feb 21:11
fd0fb23
Compare
Choose a tag to compare

[email protected]

13 Feb 17:15
96b18a7
Compare
Choose a tag to compare

Patch Changes

  • #4950 05360e43 Thanks @petebacondarwin! - fix: ensure we do not rewrite external Origin headers in wrangler dev

    In #4812 we tried to fix the Origin headers to match the Host header but were overzealous and rewrote Origin headers for external origins (outside of the proxy server's origin).

    This is now fixed, and moreover we rewrite any headers that refer to the proxy server on the request with the configured host and vice versa on the response.

    This should ensure that CORS is not broken in browsers when a different host is being simulated based on routes in the Wrangler configuration.

  • #4997 bfeefe27 Thanks @dario-piotrowicz! - chore: add missing defineNavigatorUserAgent dependency to useEsbuild hook

  • #4966 36692326 Thanks @penalosa! - fix: Report Custom Build failures as UserErrors

  • #5002 315a651b Thanks @dario-piotrowicz! - chore: rename getBindingsProxy to getPlatformProxy

    initially getBindingsProxy was supposed to only provide proxies for bindings,
    the utility has however grown, including now cf, ctx and caches, to
    clarify the increased scope the utility is getting renamed to getPlatformProxy
    and its bindings field is getting renamed env

    note: getBindingProxy with its signature is still kept available, making this
    a non breaking change

  • Updated dependencies [05360e43]:

[email protected]

13 Feb 17:15
96b18a7
Compare
Choose a tag to compare

Patch Changes

  • #4950 05360e43 Thanks @petebacondarwin! - fix: ensure we do not rewrite external Origin headers in wrangler dev

    In #4812 we tried to fix the Origin headers to match the Host header but were overzealous and rewrote Origin headers for external origins (outside of the proxy server's origin).

    This is now fixed, and moreover we rewrite any headers that refer to the proxy server on the request with the configured host and vice versa on the response.

    This should ensure that CORS is not broken in browsers when a different host is being simulated based on routes in the Wrangler configuration.

@cloudflare/[email protected]

13 Feb 17:15
96b18a7
Compare
Choose a tag to compare

Patch Changes