Skip to content

Miniflare error fetching immutable assets #8167

@dorianim

Description

@dorianim

Describe the bug

When running svelte-kit on Cloudflare or Miniflare, no assets in /_app/immutable can be fetched with the error TypeError: Cannot read properties of undefined (reading 'fetch').
I have no idea what causes this.

Reproduction

  • create a new svelte-kit project npm create svelte@latest
  • install adapter-cloudflare: npm i --safe-dev @sveltejs/adapter-cloudflare
  • change import to adapter-cloudflare in svelte.config.js
  • install miniflare npm i --save-dev miniflare
  • build and run with miniflare: npm run build && npx miniflare --debug --modules .svelte-kit/cloudflare/_worker.js
  • open http://127.0.0.1:8787/
  • error appears in console
  • open http://127.0.0.1:8787/_app/immutable/start-49f8c643.js
  • error appears in browser

Logs

[mf:inf] Listening on :8787
[mf:inf] - http://127.0.0.1:8787
[mf:inf] - http://10.37.91.138:8787
[mf:inf] - http://10.10.0.97:8787
[mf:inf] - http://10.1.1.34:8787
[mf:inf] Updated `Request.cf` object cache!
GET / 200 OK (43.86ms)
[mf:err] GET /_app/immutable/start-49f8c643.js: TypeError: Cannot read properties of undefined (reading 'fetch')
    at Object.fetch (/home/dorian/Documents/Programmieren/svelte-kit/test/.svelte-kit/cloudflare-tmp/_worker.js:51:30)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at EventTarget.[kDispatchFetch] (/home/dorian/Documents/Programmieren/svelte-kit/test/node_modules/@miniflare/core/src/standards/event.ts:385:13)
    at Server.<anonymous> (/home/dorian/Documents/Programmieren/svelte-kit/test/node_modules/@miniflare/http-server/src/index.ts:298:20)
GET /_app/immutable/start-49f8c643.js 500 Internal Server Error (344.28ms)


### System Info

```Shell
System:
    OS: Linux 5.15 Archcraft
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 4.36 GB / 15.41 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 16.18.0 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.19.2 - /usr/bin/npm
  Browsers:
    Chromium: 108.0.5359.124
    Firefox: 108.0
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.0 => 1.0.0 
    @sveltejs/adapter-cloudflare: ^1.0.0 => 1.0.0 
    @sveltejs/kit: ^1.0.0 => 1.0.0 
    svelte: ^3.54.0 => 3.55.0 
    vite: ^4.0.0 => 4.0.1

Severity

blocking all usage of SvelteKit

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationhelp wantedPRs welcomed. The implementation details are unlikely to cause debatepkg:adapter-cloudflare

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions