Skip to content

[BUG]: vite dev returns 500 on SvelteKit 3 + adapter-cloudflare 8: "no __VARLOCK_ENV binding found" #1267

Closed

Description

@f-elix

varlock version

  • varlock 1.24.0
  • @varlock/vite-integration 1.5.5
  • @varlock/cloudflare-integration 1.6.3
  • @sveltejs/kit 3.1.1, @sveltejs/adapter-cloudflare 8.0.2, wrangler 4.151.3

Steps to reproduce

  1. SvelteKit 3 app with adapter-cloudflare configured inline in vite.config.js, and varlockVitePlugin() before sveltekit(), as in the SvelteKit guide.
  2. Run vite dev.
  3. Request any SSR page.

What is expected?

The page renders, with varlock's env loaded through its normal dev flow ("vite dev runs SvelteKit's dev server; varlock resolves env via its normal flow").

What is actually happening?

Every SSR request returns 500:

Internal server error: [varlock] no __VARLOCK_ENV binding found on this Worker. Varlock injects it in `vite dev` and `vite preview`; for the built output, run and deploy through varlock's wrappers rather than the Cloudflare CLI directly. See https://varlock.dev/integrations/cloudflare/

Two recent changes combine to cause this:

So in dev, __cfEnv is the proxy's env, which has no __VARLOCK_ENV binding, and the check added in #1236 throws. With @varlock/cloudflare-integration 1.6.2 (no throw), the loader falls through, varlock loads the env normally, and dev works.

System Info

macOS 27.2, Node 24.22.1, pnpm 11.25.0

Any additional comments?

We pinned @varlock/cloudflare-integration to 1.6.2 for now. Two fixes that would work from our side: skip the throw when the vite plugin is running vite dev, or add __VARLOCK_ENV to the dev env the way varlockCloudflareVitePlugin does through wrapWorkerConfig. In a local workaround we set platform.env.__VARLOCK_ENV = process.env.__VARLOCK_ENV on the adapter's platform proxy, and that fixed it too.

Activity

  1. pullfrog commented on Nov 2, 2026

    @pullfrog
    Contributor
  2. theoephraim commented on Nov 2, 2026

    @theoephraim
    Member

    thanks so much for the report! will have this fixed ASAP

  3. github-actions commented on Nov 3, 2026

    @github-actions
    Contributor

    ✅ A fix has been merged to main in #1273 and will ship in the next release. GitHub auto-closed this issue on merge, but the change isn't published yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions