cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.56k stars 657 forks source link

🐛 BUG: Hyperdrive + Remix + Cloudflare CI build #6218

Open divyenduz opened 2 months ago

divyenduz commented 2 months ago

Which Cloudflare product(s) does this pertain to?

Pages

What version(s) of the tool(s) are you using?

3.57.1

What version of Node are you using?

v18.18.1

What operating system and version are you using?

Mac Sonoma 14.5 (23F79)

Describe the Bug

Observed behavior

With Remix template, I need to add a fake variable WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE to make the CI build pass. If I don't, the build fails with and error stating that WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE must be provided.

Expected behavior

wrangler / Cloudflare should detect that it is running in CI and let the build work.

Steps to reproduce

Please provide the following:

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

petebacondarwin commented 2 months ago

Ugh.

Hyperdrive usually just takes a UUID to connect to a cloud database, but in local dev mode, it requires a DB connection string, which can be specified either by a localConnectionString in the wrangler.toml or via an environment variable of the form WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${hyperdrive.binding}. If this is not available when running wrangler dev1 or callinggetPlatformProxy()` then you will get the error we are seeing here.

The Cloudflare Remix Vite plugin will call getPlatformProxy() in order to get access to bindings for use in vite dev mode. So (as expected) running vite dev will trigger this error. One would expect this not to get loaded when running vite build but it turns out that the Remix Vite plugin creates a "child compiler" that is a local Vite Server, which in turn results in the getPlatformProxy() being called.

petebacondarwin commented 2 months ago

It feels like this is a problem with the upstream Remix plugins...?

petebacondarwin commented 2 months ago

Just assigning to @dario-piotrowicz to remind us to discuss this with Remix...