@rsc-kit/mcp 0.28.0 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/recipes.js CHANGED
@@ -1867,6 +1867,39 @@ TABLE - the app owns rsc_versions (rsc-kit never creates/alters it at
1867
1867
  runtime): name TEXT PRIMARY KEY (MySQL: VARCHAR(255)), version BIGINT NOT
1868
1868
  NULL. Extra columns fine if they have defaults. Drizzle: a pgTable in your
1869
1869
  schema + createVersions with the query builder (not raw SQL).
1870
+ POOLERS - a pooler in TRANSACTION mode (PgBouncer; DigitalOcean/Supabase/Neon
1871
+ pooled URLs) silently drops LISTEN. postgresVersions probes once as it starts
1872
+ listening; if deaf it logs why and reads every second. Fix:
1873
+ postgresVersions(pool, { listenWith: directOrSessionModeClient }) - one extra
1874
+ connection per process; reads/writes stay on the pool. (await connection() is
1875
+ unrelated: it is about rendering per request.)
1876
+ POLL ON PURPOSE - postgresVersions(pool, { listen: false }) when direct
1877
+ connections are scarce: no listener, no probe, no warning; one indexed read per
1878
+ second per process for all its tabs; other instances' changes within ~1s.
1879
+ WORKERS / SERVERLESS - the stream is stateless (signed names) so it runs where
1880
+ responses stream, but: each isolate/instance watches for its own tabs, so
1881
+ in-memory versions are useless - use a shared store. Platform request limits
1882
+ cut streams (they reconnect and catch up); billed-per-second functions pay for
1883
+ every watching tab; Hyperdrive/serverless drivers can't LISTEN (probe falls back
1884
+ to 1s, or listen: false). No streaming at all: usePolling.
1885
+ CLOUDFLARE WORKERS + D1 (verified on wrangler dev; examples/cloudflare /live):
1886
+ // src/versions.ts - import the binding INSIDE the query: the build prerenders
1887
+ // in Node, runs register(), and cannot load 'cloudflare:workers' (a top-level
1888
+ // import breaks the build).
1889
+ const db = async () => (await import('cloudflare:workers')).env.DB
1890
+ export const versions = () => sqlVersions({ dialect: 'sqlite',
1891
+ query: async (t, p) => (await (await db()).prepare(t).bind(...p).all()).results })
1892
+ // src/instrumentation.ts: installVersionSource(versions)
1893
+ // wrangler.jsonc (Nitro merges it): "d1_databases": [{ "binding": "DB",
1894
+ // "database_name": "my-app", "database_id": "<id>", "migrations_dir": "migrations" }]
1895
+ // migrations/0001_rsc_versions.sql:
1896
+ // CREATE TABLE IF NOT EXISTS rsc_versions (name TEXT PRIMARY KEY, version BIGINT NOT NULL);
1897
+ // npx wrangler d1 migrations apply DB --remote (--local for wrangler dev)
1898
+ // npx wrangler secret put RSC_SIGNING_SECRET (.dev.vars for wrangler dev)
1899
+ // A section reading D1 itself: await connection() first - D1 is per request.
1900
+ INSTALL LAZILY - installVersionSource(() => postgresVersions(client)): a
1901
+ factory, made on first use. register() also runs in the build, often without
1902
+ DB settings; a store made there makes its client there.
1870
1903
  LISTEN THROUGH AN ORM - pass the driver's listen/notify to createVersions:
1871
1904
  Drizzle on Bun.sql: listen: wake => client.listen('rsc_versions', wake),
1872
1905
  notify: () => client.notify('rsc_versions', '') with the SQL client you gave