Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-pets-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sveltejs/adapter-cloudflare": patch
---

fix(adapter-cloudflare): await initialization on every request to prevent race condition
Comment thread
teemingc marked this conversation as resolved.
Outdated
4 changes: 3 additions & 1 deletion packages/adapter-cloudflare/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ export default {
async fetch(req, env, ctx) {
if (!origin) {
origin = new URL(req.url).origin;
await initialized;
}

// always await initialization to prevent race condition with concurrent requests
await initialized;

// skip cache if "cache-control: no-cache" in request
let pragma = req.headers.get('cache-control') || '';
let res = !pragma.includes('no-cache') && (await Cache.lookup(req));
Expand Down
Loading