Releases: cloudflare/workers-sdk
[email protected]
Patch Changes
-
#5066
ef064279
Thanks @dependabot! - chore: Bumpedcreate-remix
from2.6.0
to2.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 theenv
property. These types can be re-generated with a newly addedbuild-cf-types
script.
@cloudflare/[email protected]
[email protected]
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 nameThis 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]
Patch Changes
-
#5026
04584722
Thanks @dario-piotrowicz! - fix: make suregetPlatformProxy
produces a production-likecaches
objectmake sure that the
caches
object returned togetPlatformProxy
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 GitHubWrangler 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 variableWrangler 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 pressingb
would openlocalhost: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 thegetPlatformProxy
's' cache request/response typesprior to these changes the caches obtained from
getPlatformProxy
would useunknown
s as their types, this proved too restrictive
and incompatible with the equivalent@cloudflare/workers-types
types, we decided to useany
s 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]
Minor Changes
-
#4795
027f9719
Thanks @mrbbot! - feat: passMiniflare
instance as argument to custom service binding handlersThis 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: allowURL
s to be passed inhyperdrives
Previously, the
hyperdrives
option only acceptedstring
s as connection strings. This change allowsURL
objects to be passed too. -
#4795
027f9719
Thanks @mrbbot! - feat: add support for custom root pathsMiniflare 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 newrootPath
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 closestrootPath
option. Paths are still resolved relative to the current working directory if norootPath
s are defined. Worker-levelrootPath
s are themselves resolved relative to the sharedrootPath
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 workerPreviously, 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 inserviceBindings
.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 relativescriptPath
/modulesRoot
s to break out of current working directoryPreviously, Miniflare would resolve relative
scriptPath
s againstmoduleRoot
multiple times resulting in incorrect paths and module names. This would lead tocan't use ".." to break out of starting directory
workerd
errors. This change ensures Miniflare usesscriptPath
as is, and only resolves it relative tomodulesRoot
when computing module names. Note this bug didn't affect service workers. This allows you to reference a modulesscriptPath
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 upgradingfetch()
esPreviously, Miniflare's
fetch()
would throw an error if theUpgrade: websocket
header was set, and a non-WebSocket response was returned from the origin. This change ensures the non-WebSocket response is returned fromfetch()
instead, withwebSocket
set tonull
. This allows the caller to handle the response as they see fit. -
#4795
027f9719
Thanks @mrbbot! - fix: ensureMiniflareOptions
,WorkerOptions
, andSharedOptions
types are correctMiniflare 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, thehyperdrives
option has different input/output types, preventing these from being type checked correctly.
[email protected]
Minor Changes
-
#4996
246512c8
Thanks @jculvey! - feature: AddgetBindingsProxy
support tonuxt
template vianitro-cloudflare-dev
module.The
nuxt
template now uses the default dev command fromcreate-nuxt
instead of usingwrangler pages dev
on build output in order to improve the developer workflow.nitro-cloudflare-dev
is a nitro module that leveragesgetBindingsProxy
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. Awrangler.toml
file will also be added where bindings can be added to be used in conjunction withgetPlatformProxy
.Along with this change, projects will use the default vite-based dev command from
create-svelte
instead of usingwrangler pages dev
on build output.When Typescript is used, the
app.d.ts
will be updated to add type definitions forcf
andctx
to thePlatform
interface from the@cloudflare/workers-types
package. Types for bindings onplatform.env
can be re-generated with a newly addedbuild-cf-types
script.
Patch Changes
-
#5001
efe8b444
Thanks @dependabot! - chore: Bumpedcreate-hono
from0.3.2
to0.4.0
-
#5011
89482d44
Thanks @dependabot! - chore: Bumpedcreate-qwik
from1.4.4
to1.4.5
-
#5019
f939ed73
Thanks @dependabot! - chore: Bumped@angular/create
from17.1.3
to17.2.0
-
#5020
0e74c743
Thanks @dependabot! - chore: Bumpednuxi
from3.10.0
to3.10.1
-
#5021
ae1ef47c
Thanks @dependabot! - chore: Bumpedcreate-astro
from4.7.2
to4.7.3
-
#5009
1e263694
Thanks @dario-piotrowicz! - chore: update Next.js templateUpdate the C3 Next.js template so that it uses the latest
@cloudflare/next-on-pages
tooling (i.e.setupDevPlatform
andgetRequestContext
) -
#4996
246512c8
Thanks @jculvey! - feature: Add an emptywrangler.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 typescriptcurrently 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 usegetPlatformProxy
update the C3 Qwik template to use the
getPlatformProxy
utility instead of the deprecatedgetBindingsProxy
one
@cloudflare/[email protected]
[email protected]
Patch Changes
-
#4950
05360e43
Thanks @petebacondarwin! - fix: ensure we do not rewrite external Origin headers in wrangler devIn #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 missingdefineNavigatorUserAgent
dependency to useEsbuild hook -
#4966
36692326
Thanks @penalosa! - fix: Report Custom Build failures asUserError
s -
#5002
315a651b
Thanks @dario-piotrowicz! - chore: renamegetBindingsProxy
togetPlatformProxy
initially
getBindingsProxy
was supposed to only provide proxies for bindings,
the utility has however grown, including nowcf
,ctx
andcaches
, to
clarify the increased scope the utility is getting renamed togetPlatformProxy
and itsbindings
field is getting renamedenv
note:
getBindingProxy
with its signature is still kept available, making this
a non breaking change -
Updated dependencies [
05360e43
]:
[email protected]
Patch Changes
-
#4950
05360e43
Thanks @petebacondarwin! - fix: ensure we do not rewrite external Origin headers in wrangler devIn #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]
Patch Changes
- Updated dependencies [
05360e43
]: