Skip to content

runtime-ts: Hono CRUD helpers call SQLite-only .all()/.get(), 500 on Postgres (Fastify adapter already has the fix) #286

Closed

Description

@dmealing

Summary

Every list/get route mounted through @metaobjectsdev/runtime-ts/hono returns HTTP 500 on a Postgres project, because the Hono adapter calls Drizzle's libsql/better-sqlite3-only .all() / .get() terminal methods. drizzle-orm/postgres-js's query builder has neither — it is thenable and must simply be awaited.

The fix already exists in this repo, in the sibling Fastify adapter, with a comment explaining precisely this. It was never ported to the Hono adapter.

Evidence

dist/drizzle-fastify/index.js:130-134 — correct, and self-documenting:

// Await the query directly rather than calling `.all()`: the
// drizzle-orm node-postgres query builder is thenable but has no `.all()`
// method (that is a libsql/better-sqlite3-only API). Awaiting works on
// both dialects and is what makes this helper genuinely Postgres-capable.
const rows = await q;

dist/hono/index.js — still the old form:

:90   const rows = await q.all();
:97   const countRow = (await cq.all())[0];
:121  .get();

Same in dist/hono/mount-read-only.js:103,109,140.

Symptom

TypeError: q.all is not a function

on any GET /api/<entity> or GET /api/<entity>/:id served by mountCrudRoutes / mountReadOnlyCrudRoutes / mountListRoute / mountGetRoute from @metaobjectsdev/runtime-ts/hono, against drizzle-orm/postgres-js.

POST / PATCH / DELETE are unaffected — they don't use those terminal methods.

Affected versions

Reproduced on 0.21.2. 0.21.3 was unpacked and inspected and contains the same unfixed code (not installed).

Suggested fix

Apply the Fastify adapter's already-proven change to hono/index.js and hono/mount-read-only.js:

  • await q.all() → await q
  • .get() → await q and take [0] (or .limit(1) then index)

Impact

This makes routesFileHono() unusable end-to-end on Postgres, which is the combination the Hono adapter most plausibly targets (Hono is commonly paired with Postgres on Node/Bun as well as with D1/SQLite on Workers). An adopter following the metaobjects-runtime-ui skill's own guidance — "mount the standard verbs with these helpers and hand-write only the custom routes" — hits it immediately on the first GET.

There appears to be no cross-adapter conformance test covering list/get against Postgres for the Hono adapter; the Fastify adapter's fix having landed without the Hono one suggests the two adapters aren't exercised by a shared dialect matrix. That may be worth more than the one-line fix.

Context

Reported from a real adopting project (Bun + Hono + drizzle-orm/postgres-js + PostgreSQL 16), which is generating its entire REST surface from metadata rather than hand-writing CRUD. We deliberately did not hand-write substitute routes or locally patch the dependency, and are reporting instead.

Related, same adopter, still open: #285 (migrate emits DROP INDEX for a unique-constraint-backed index).

Activity

  1. dmealing commented on Aug 9, 2026

    @dmealing
    MemberAuthor

    Fixed on main in 0dd925fd — ships in the next release.

    Your diagnosis was exact, including that the fix already existed in the Fastify adapter. All six Hono call sites now use the portable form: await q for lists, .limit(1) + [0] for single-row reads.

    You were right that the signal matters more than the one-liner, so that's where most of the work went. The reason Fastify's fix landed alone is that every adapter test in the package used libsql — where .all()/.get() exist and work. No test could have caught this for either adapter; Fastify's fix was reasoned, not gated. A per-adapter suite with a single dialect structurally cannot detect a dialect divergence.

    So there's now a cross-adapter dialect matrix against a real Postgres: the same read paths (list, get-by-id, 404, withCount envelope, filter+sort) asserted across Fastify and Hono, plus a payload-equality check between them. Adding a third adapter means adding a row, not a new file. Verified to reproduce your q.all is not a function on four tests with the fix reverted.

    One wrinkle worth recording: runtime-ts's suite runs in the ts-unit CI lane, which has no database — so a Postgres test there would have skipped forever. The matrix is wired into ts-slow (the lane with the sidecar), next to the migrate-ts real-PG gate, with the same loud-skip sentinel: a lane that declares it intends Postgres and then doesn't supply it now fails instead of skipping silently.

    Re #285 — already fixed earlier today in f6a4ce6f, also on main and unreleased. Glad the rebuild-from-metadata route unblocked you; you were right that Drizzle adopters will hit it, since unique() produces constraints rather than bare indexes. Introspection now reads pg_constraint.conindid and the emitter drops the constraint instead.

    Thanks for not hand-writing substitute routes or patching the package locally — keeping the failure intact is what made both of these diagnosable rather than folklore.

  2. dmealing commented on Aug 9, 2026

    @dmealing
    MemberAuthor

    Fixed and released in 0.21.4 (npm @metaobjectsdev/[email protected]).

    All six Hono call sites now use the portable form — await q for lists, .limit(1) + [0] for single-row reads — instead of Drizzle's libsql/better-sqlite3-only .all()/.get(). You had it exactly right that the Fastify adapter already carried the fix; it simply never got ported.

    On why this shipped broken through 0.21.2 and 0.21.3: runtime-ts's own suite runs in a lane with no database, and every adapter test there used libsql — precisely where .all()/.get() work. The dialect matrix now runs against a real Postgres through both entry points, so an adapter cannot diverge from its sibling silently again.

    See CHANGELOG.md [0.21.4].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions