Conversation
- ensureSearchHealthy() uses the singleton DB so index rebuilds land on the primary instead of whichever replica the request session happened to route to. - Playground request context now carries dbIsIsolated so per-session DO schemas don't accidentally share module-scope cache entries.
🦋 Changeset detectedLatest commit: 8341151 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR template validation failedPlease fix the following issues by editing your PR description:
See CONTRIBUTING.md for the full contribution policy. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 8341151 | Apr 17 2026, 06:56 PM |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
Pull request overview
Follow-up correctness fix to the cold-start/runtime work from #631, ensuring search index repair operations and schema-derived caches behave safely under D1 Sessions and isolated playground databases.
Changes:
- Run
ensureSearchHealthy()against the runtime singleton DB (this._db) so any repair/rebuild writes cannot route to a replica via request-scoped D1 Sessions DB. - Mark playground DO-backed DB overrides as isolated (
dbIsIsolated: true) so module-scoped schema-derived caches are bypassed per session. - Add a changeset documenting the two fixes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/emdash-runtime.ts | Switches ensureSearchHealthy() to use the singleton DB and updates docstring to match actual callers + D1 Sessions routing constraints. |
| packages/core/src/astro/middleware/request-context.ts | Ensures playground ALS context sets dbIsIsolated: true to prevent cross-session cache reuse with divergent schemas. |
| .changeset/pr-631-followup.md | Adds release note describing the two correctness fixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Follow-up to #631. Addresses two real issues raised in the Copilot review:
ensureSearchHealthy()was callingFTSManagerwiththis.db, which on GET search requests is a D1 Sessions Kysely bound tofirst-unconstrainedrouting. The verify step reads, but a mismatched row count triggers a rebuild write, which can land on a replica instead of the primary. Switched tothis._db(singleton) so repair writes always route to the primary via the adapter's ownfirst-primarypromotion.request-context.tsmiddleware was creating an ALS context withoutdbIsIsolated, which meant module-scoped caches (manifest, taxonomy defs, byline/term probes) would be reused across playground sessions with independent schemas. Added the flag.Also tidied the
ensureSearchHealthydocstring; the original mentioned "admin routes" as callers but only the search/suggest endpoints actually call it.The two other review comments are left unaddressed intentionally:
getRuntimerisks stack overflow" —awaitsuspends the stack, so recursion through async calls doesn't accumulate frames the way sync recursion does. The loop form would be functionally identical; not worth changing.Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (2395)pnpm formathas been runAI-generated code disclosure