Skip to content

fix: comments work again on Cloudflare; read_drop returns content when comments can't be read - #106

Merged
vite-hub[bot] merged 2 commits into
mainfrom
fix/comments-d1-install
Nov 2, 2026
Merged

vite-hub[bot] merged 2 commits into
mainfrom
fix/comments-d1-install

Conversation

@onmax

@onmax onmax commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

What broke

Since #64/#105 (the move to ViteHub Comments on 0.1.0) were deployed, every comments call on drop.vitehub.dev answers 503: "The Comments runtime has no Database yet". That covers the viewer's comments, posting, and MCP read_drop. Workers Observability shows every COMMENTS_NOT_INSTALLED coming from one Worker version, 108f48a6, which is the current deploy.

Why

The plugin that ViteHub generates for server/comments.ts picks the Database when the Worker starts. It reads databases.default.db.select to check that a default Database exists. On Cloudflare that runs before any request, so there is no D1 binding yet, and the read throws. A bare catch {} took that for "no Database", so Comments was never installed. The warning prints at global scope, which Workers Logs doesn't keep. This isn't a binding or config problem: DB is bound, and publish and list_drops use it.

Change

  • patches/@vite-hub__comments@0.1.0.patch: in the generated plugin, only DATABASE_DISABLED (no default Database) counts as "none". Any other error keeps the D1 db, which connects per query. Upstream fix: fix(comments): install Comments on Cloudflare D1, which connects only when a request arrives vitehub#3222. Remove the patch when that ships.
  • read_drop still returns the drop's content, versions, answers and files when comments can't be read (a 503 from Comments), for docs and sites. Where the comments would go, it says they couldn't be read and that the drop may have open comments, so an agent doesn't take an empty list for "no comments". structuredContent gets commentsUnavailable.

Verified

  • I built the Worker (nuxt build) and ran it under wrangler dev with a local D1. I signed up, published a doc, posted a comment, and listed the comments. With the patch, both calls return 200 and the comment. With the old catch {} put back into the built chunk, both return the prod 503, and the Worker logs Comments has no Database at startup.
  • test/mcp/comments-unavailable.test.mjs runs read_drop with Comments left uninstalled. It fails on main with the prod error and passes here. test/mcp, test/quiz/answers, and test/review/review pass (81 tests). Lint and format are clean on the changed files.

To deploy

Merging and deploying the Worker is enough: no binding, secret or migration changes. Quiver (Node + SQLite on GKE, still on 7c33833 from before #64) doesn't have this bug: libSQL connects at startup there. When Quiver moves past #64, it gets this patch along with it.

🤖 Generated with Claude Code

…s content when comments can't be read

ViteHub's Comments plugin probed D1 when the Worker started, before any request brought the
binding, and left Comments without a Database. Every comments call answered 503. Patched from
vite-hub/vitehub#3222.
@vite-hub

vite-hub Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Waiting 2026-11-02T08:25:51.956Z 5m 53s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Waiting for GitHub merge request 9591e114-9073-4d51-a5d3-75e202d5346e.

Session

Pushed 422f9ad fixing Doctor TS0008 with an explicit return type and no assertion. Doctor, focused vp lint, vp fmt --check, and both comments-unavailable tests passed using local binaries. Emitted JavaScript is unchanged. Both supplied reviews reported no findings. Dependency setup encountered pnpmfileChecksum and protected Git metadata errors; installed tools completed validation. Awaiting CI.

View session

Pushed 422f9ad fixing Doctor TS0008 with an explicit return type and no assertion. Doctor, focused vp lint, vp fmt --check, and both comments-unavailable tests passed using local binaries. Emitted JavaScript is unchanged. Both supplied reviews reported no findings. Dependency setup encountered pnpmfileChecksum and protected Git metadata errors; installed tools completed validation. Awaiting CI.

Session

Waiting for review checks before the next pass.

Session

Waiting for review checks before the next pass.

Session

Waiting for review checks before the next pass.

Session

Waiting for review checks before the next pass.

Session

Waiting for review checks before the next pass.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T08:19:20.491523Z 677abf6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes covering the Cloudflare Comments database-selection fix and the read_drop degradation path when comment reads are unavailable.

  • Cloudflare database selection — patches the generated Comments plugin to retain a configured request-scoped D1 proxy while still recognizing an intentionally disabled default Database.
  • MCP partial availability — returns drop/site content and metadata when comment listing returns a 503, while explicitly marking comments as unavailable rather than reporting none.
  • Regression coverage — adds an uninstalled-Comments harness mode and MCP tests for both document and site reads.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@vite-hub
vite-hub Bot merged commit 94807ba into main Nov 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant