adapter-cloudflare 4.2.0 broke waitUntil use inside hooks.server.ts (with prerendering)
Open
Nobody has claimed this yet.
needs-decision
pkg:adapter-cloudflare
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
Using adapter-cloudflare 4.1.0, npm run build works fine. Upgrading to 4.2.0 causes npm run build to fail with:
✓ built in 3.21s
TypeError: Cannot read properties of undefined (reading 'waitUntil')
/Users/maemigh/arcana-website/node_modules/wrangler/wrangler-dist/cli.js:29573
throw a;
^
Error: 500 /about
To suppress or handle this error, implement `handleHttpError` in https://kit.svelte.dev/docs/configuration#prerender
at file:///Users/maemigh/arcana-website/node_modules/@sveltejs/kit/src/core/config/options.js:202:13
at file:///Users/maemigh/arcana-website/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:65:25
at save (file:///Users/maemigh/arcana-website/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:403:4)
at visit (file:///Users/maemigh/arcana-website/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:236:3)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v21.5.0
Reproduction
use event.platform.context.waituntil inside hooks.server.ts and use prerendering
Logs
No response
System Info
System:
OS: macOS 14.3.1
CPU: (8) arm64 Apple M1
Memory: 58.55 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.5.0 - /opt/homebrew/bin/node
npm: 10.2.4 - /opt/homebrew/bin/npm
pnpm: 8.7.0 - ~/Library/pnpm/pnpm
Browsers:
Brave Browser: 122.1.63.174
Edge: 122.0.2365.92
Firefox Nightly: 92.0a1
Safari: 17.3.1
npmPackages:
@sveltejs/adapter-auto: ^3.0.0 => 3.1.1
@sveltejs/adapter-cloudflare: ^4.2.0 => 4.2.0
@sveltejs/kit: ^2.0.6 => 2.5.0
@sveltejs/vite-plugin-svelte: ^3.0.0 => 3.0.2
svelte: ^4.2.8 => 4.2.9
vite: ^5.0.0 => 5.0.12
npx wrangler -v
⛅️ wrangler 3.34.2
-------------------
Severity
blocking an upgrade
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with adapter-cloudflare 4.2.0 using npm run build, prerendering, and waitUntil in hooks.server.ts; compare it with adapter-cloudflare 4.1.0. Trace the prerender failure around the undefined platform context. Done means the prerendered build completes without the waitUntil error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, typescript
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100