Patch Changes
-
#605
445b3bfThanks @ascorbic! - Fixes D1 read replicas being bypassed for anonymous public page traffic. The middleware fast path now asks the database adapter for a per-request scoped Kysely, so anonymous reads land on the nearest replica instead of the primary-pinned singleton binding.All D1-specific semantics (Sessions API, constraint selection, bookmark cookie) live in
@emdash-cms/cloudflare/db/d1behind a singlecreateRequestScopedDb(opts)function. Core middleware has no D1-specific logic. Adapters opt in via a newsupportsRequestScope: booleanflag onDatabaseDescriptor;d1()sets it to true.Other fixes in the same change:
- Nested
runWithContextcalls in the request-context middleware now merge the parent context instead of replacing it, so an outer per-request db override is preserved through edit/preview flows. - Baseline security headers now forward Astro's cookie symbol across the response clone so
cookies.set()calls in middleware survive. - Any write (authenticated or anonymous) now forces
first-primary, so an anonymous form/comment POST isn't racing across replicas. - The session user is read once per request and reused in both the fast path and the full runtime init (previously read twice on authenticated public-page traffic).
- Bookmark cookies are validated only for length (≤1024) and absence of control characters — no stricter shape check, so a future D1 bookmark format change won't silently degrade consistency.
- The
!configbail-out now still applies baseline security headers. __ec_d1_bookmarkreferences aligned to__em_d1_bookmarkacross runtime, docs, and JSDoc.
- Nested
-
#569
134f776Thanks @Yusaku01! - Fixes the playground toolbar layout on small screens. -
#653
f97d6abThanks @ascorbic! - Adds opt-in query instrumentation for performance regression testing. SettingEMDASH_QUERY_LOG=1causes the Kysely log hook to emit[emdash-query-log]-prefixed NDJSON on stdout for every DB query executed inside a request, tagged with the route, method, and anX-Perf-Phaseheader value. Zero runtime overhead when the flag is unset — the log option is only attached to Kysely when enabled.Also exposes the helpers at
emdash/database/instrumentationso first-party adapters (e.g.@emdash-cms/cloudflare) can wire the same hook into their per-request Kysely instances. -
Updated dependencies [
ada4ac7,f279320,7f75193,cfd01f3,38d637b,31d2f4e,445b3bf,943d540,2cb3165,1859347,14c923b,c5ef0f5,f839381,002d0ac,0a61ef4,6d41fe1,b158e40,f97d6ab,e67b940,0896ec8,629fe1d,f52154d,8221c2a,8fb93eb,6d7f288,4ffa141,04e6cca,9295cc1]:- emdash@0.6.0