Patch Changes
-
#333
6320a32
Thanks @threepointone! - fix: pass worker name to syncAssets indev
This fix passes the correct worker name to
syncAssets
duringwrangler dev
. This function uses the name to create the backing kv store for a Workers Sites definition, so it's important we get the name right.I also fixed the lint warning introduced in #321, to pass
props.enableLocalPersistence
as a dependency in theuseEffect
call that starts the "local" mode dev server. -
#335
a417cb0
Thanks @threepointone! - fix: prevent infinite loop when fetching a list of resultsWhen fetching a list of results from cloudflare APIs (e.g. when fetching a list of keys in a kv namespace), the api returns a
cursor
that a consumer should use to get the next 'page' of results. It appears this cursor can also be a blank string (while we'd only account for it to beundefined
). By only accounting for it to beundefined
, we were infinitely looping through the same page of results and never terminating. This PR fixes it by letting it be a blank string (andnull
, for good measure) -
#332
a2155c1
Thanks @threepointone! - fix: wait for port to be available before creating a dev serverWhen we run
wrangler dev
, we start a server on a port (defaulting to 8787). We do this separately for both local and edge modes. However, when switching between the two with thel
hotkey, we don't 'wait' for the previous server to stop before starting the next one. This can crash the process, and we don't want that (of course). So we introduce a helper functionwaitForPortToBeAvailable()
that waits for a port to be available before returning. This is used in both the local and edge modes, and prevents the bug right now, where switching between edge - local - edge crashes the process.(This isn't a complete fix, and we can still cause errors by very rapidly switching between the two modes. A proper long term fix for the future would probably be to hoist the proxy server hook above the
<Remote/>
and<Local/>
components, and use a single instance throughout. But that requires a deeper refactor, and isn't critical at the moment.) -
#336
ce61000
Thanks @threepointone! - feat: inline text-like files into the worker bundleWe were adding text-like modules (i.e.
.txt
,.html
and.pem
files) as separate modules in the Worker definition, but this only really 'works' with the ES module Worker format. This commit changes that to inline the text-like files into the Worker bundle directly.We still have to do something similar with
.wasm
modules, but that requires a different fix, and we'll do so in a subsequent commit. -
#336
ce61000
Thanks @threepointone! - feat: Sites support for local modewrangler dev
This adds support for Workers Sites in local mode when running wrangler
dev
. Further, it fixes a bug where we were sending the__STATIC_CONTENT_MANIFEST
definition as a separate module even with service worker format, and a bug where we weren't uploading the namespace binding when other kv namespaces weren't present.