Skip to content

skezo/astro-cf-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

astro-cf-repro

Minimal repro for a build crash with @astrojs/cloudflare when experimental.advancedRouting uses a custom fetchFile.

Steps

pnpm install
pnpm build

Result

(0 , __vite_ssr_import_0__.createGetEnv) is not a function
  at runInRunnerObject (workers/runner-worker/index.js:107:3)

Notes

  • src/worker.ts is the fetchFile. It imports cf from @astrojs/cloudflare/fetch.
  • Set experimental.advancedRouting to true and the build passes, because virtual:astro:fetchable falls back to DefaultFetchHandler and never imports @astrojs/cloudflare/fetch.
  • It's a circular import: fetch.js runs setGetEnv(createGetEnv(globalEnv)) and createApp() at module top level. createApp comes from astro/app/entrypoint, which imports virtual:astro:fetchable, which re-exports worker.ts, which imports @astrojs/cloudflare/fetch again.
  • Importing cf lazily inside the handler (const { cf } = await import('@astrojs/cloudflare/fetch')) breaks the static back-edge and the build passes.

About

Minimal repro: @astrojs/cloudflare advancedRouting fetchFile build crash (createGetEnv is not a function)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors