Repository navigation
Closed
Labels
Milestone
Description
Goal
Raise @docs.plus/hocuspocus from Prisma 6.19.3 to 7.10.1, by ruling 5 on #575. Make the Prisma schema the only owner of document row types. Keep Zod as the write contract. Keep webapp and admin on wire types only.
Facts (2026-08-27)
- Pins today:
prisma,@prisma/client, and@prisma/adapter-pgat^6.19.3. Lock resolves6.19.3. - Latest generally available Prisma is 7.10.0 (npm dist-tag
prev). 7.10.0 · Upgrade to v7 - npm
latestis Prisma 8 RC (8.0.0-rc.12on this date). Do not take 8. Pin7.10.0. Never writeprisma@latest. Ruling 5 now pins7.10.1. - The adapter path is already live.
src/lib/prisma.tsconstructsPrismaPgand passesadapterintoPrismaClient. - Generator is still
prisma-client-jswithpreviewFeatures = ["fullTextSearchPostgres"]. Prisma 7 wantsprisma-client, a requiredoutput, andprisma.config.ts. - Six sites hardcode
bunx [email protected]: Docker generate, entrypoint, compose migrate,start-production.ts, andfix-migration.ts.scripts/setup.shstill says6.19.0. Move them together or boot drifts. - Settings search uses
{ search: }on title, keywords, and description. Confirm that filter after the bump. $on('query'|'error'|'warn' as never, …)is a typing workaround. Re-type it on the v7 client.- Root
[email protected]exists because Prisma 6's@prisma/configpulled7.1.5. Drop the pin only after Prisma 7 stays green underbun audit. - Inside hocuspocus, production already imports
DocumentMetadatafrom@prisma/client. A hand copy insrc/types/document.types.tsomitsdeletedAtand must go. - Zod
document.schema.tsis the write contract.keywordsisstring[]on the wire andString?in Prisma. The service already splits CSV. Keep that transform. - Webapp and admin never import
@prisma/client. That split stays.fetchDocument.tslost its[key: string]: anyin633972f69on 2026-10-19. ItsDocumentDatatype now lists the slug-read fields.VersionTriggeris copied in webapptypes/history.ts. DocumentClientAuthor.clientIdisBigIntin Prisma andnumberon the wire. Document that contract. Do not change it silently.DocumentMetadata.emailis the one stale cross-store copy. Dropping it is a later change. Not this ticket.- Storage design stays: one full Yjs snapshot per version.
@@index([documentId])stays. Seeapps/hocuspocus.server/CLAUDE.md. - Upgrade Bun to 1.4 and measure test plus backend wins #171 already says do not replace Prisma with
Bun.SQL. This ticket is the Prisma bump. Upgrade Bun to 1.4 and measure test plus backend wins #171 is not this work.
Backlog row: O8 in BACKLOG-hocuspocus-backend.md.
What to build
One change. Bump and type accountability land together.
- Pin
prisma,@prisma/client, and@prisma/adapter-pgto7.10.1. Addprisma.config.ts. Switch the generator. Point every import at the new client output. - Replace every hardcoded
bunx [email protected](and the6.19.0setup hint) with the new pin in the same change. - Keep the existing
PrismaPgpool. Do not invent a second pool. Stripconnection_limitfrom any URL the CLI migrate path still sees, if 7 rejects it. - Confirm Settings search, persist (a version row), and every
P2002cede still behave. Re-type$on. Re-checkBytes/Uint8ArrayonFOR UPDATEraw reads. - Delete the hand
DocumentMetadata. Use generated Prisma types inside hocuspocus only. - Keep Zod as the only write contract. Deduplicate
VersionTriggerso webapp imports the wire union, not a second literal. - Already done:
633972f69closedfetchDocument.ts's index signature and typed the slug-read DTO. Confirm it still holds after the bump. - Re-check
deepmerge-tsafter the bump. Keep or drop the pin frombun audit, not from a blog.
Out of scope
- Prisma 8, including a side-by-side
@prisma/prisma7install. - Storage redesign, delta snapshots, or dropping
@@index([documentId]). - A new workspace types package.
- Importing
@prisma/clientinto webapp or admin. - Dropping
DocumentMetadata.email. - Replacing Prisma with
Bun.SQL(that is a Upgrade Bun to 1.4 and measure test plus backend wins #171 ban). - Dynamic slugs.
Acceptance criteria
-
prisma -vand@prisma/clientare7.10.1.git grep -niE 'prisma(@|.*\^)6\.19|Prisma 6\.19' -- . ':!*CHANGELOG*' ':!bun.lock'finds nothing. At HEAD it finds 14 sites,setup.shandfix-migration.tsincluded. -
prisma generateandprisma migrate deploywork locally and in the image. REST on:4000, WS, and worker start. - Settings search still returns matches. A pad persist still mints a
Documentsrow. A slugP2002cede still returns. - hocuspocus
bun testis green. The store-pipeline or versions e2e that you can run locally is green. - No hand
DocumentMetadata. Webapp and admin still have zero@prisma/clientimports. -
fetchDocumentstill has no[key: string]: any(done in633972f69).VersionTriggerhas one source. -
bun auditresult fordeepmerge-ts/@prisma/configis recorded. The pin is kept or dropped from that result.
Blocked by
None. Can start immediately. Does not depend on #171 or #172. Do not fold this into the Bun soak.
Activity
[-]Upgrade Prisma to 7.10.0 and make document types accountable[/-][+]Upgrade Prisma to 7.10.1 and make document types accountable[/+]HMarzban commentedon Oct 24, 2026
Update, 2026-10-24: target 7.10.1, and two performance checks
Version. Prisma 7.10.1 is the newest general release, published on 2026-10-15. It is the
latestdist-tag of@prisma/client. Thelatestdist-tag of theprismapackage points at8.0.0-rc.27, a release candidate. Take 7.10.1 wherever this issue says 7.10.0. Never writeprisma@latest. The count of pinned sites has also grown. Move all of these in one change:bunx [email protected]sites:apps/hocuspocus.server/docker/Dockerfile.bun:63,:94and:109,scripts/docker-entrypoint.sh:14,scripts/start-production.ts:11and:32,scripts/fix-migration.ts:10, anddocker-compose.prod.yml:168;[email protected]lines inapps/hocuspocus.server/scripts/setup.sh:30and:46.Why the upgrade matters for speed.
@prisma/[email protected]runsArray.from(new Uint8Array(buffer))on everybyteavalue (dist/index.mjs:289). That builds one JS number per stored byte. 7.1.0 still has the copy. 7.2.0, 7.10.0 and 7.10.1 returnparsePgBytesdirectly.Measured locally on 2026-10-23, the Prisma
bytearead is the main cost in three paths:Array.fromalone timed at about 7–9 ms/MB. So the upgrade removes the copy, but maybe not the whole cost. The rest may be the Prisma 6 engine hop.New acceptance items.
ENABLE_SCHEMA_MIGRATIONis on in production (Run the production reads that the 2026-10-23 backend perf plan needs #576), because it adds a second decode on cold load.Rules that still hold. Keep the existing
PrismaPgpool, and do not build a second pg pool. Do not routebyteareads through$queryRaweither, because the adapter parses raw queries too.Decisions. Owner: the maintainer (rulings 5 and 6 on #575).
translate(encode(data,'base64'), E'\n', ''), which returns text and skips the adapter's byte conversion. It cut the watch read block from 119.65 ms to 3.69 ms locally. Recommended: wait, because this issue is now in v2.3.0. Decide once for allbyteareads, not read by read.This issue is now in milestone v2.3.0, under #575. #214 and #597 wait on it. #593 may change the
P2002cede path first; if it does, re-check itscountpath here.HMarzban commentedon Oct 24, 2026
Maintainer ruling, 2026-10-24
Decision 2: wait for this upgrade. Do not ship the base64 stopgap on the
history.watchor digest reads. #214 step 1 and #597 wait on this issue.Decision 1 (which Prisma version) is still open.
HMarzban commentedon Oct 24, 2026
Maintainer ruling, 2026-10-24
Decision 1: take Prisma 7.10.1 now. Do not take the Prisma 8 release candidate. Prisma 8 moves to #604, after it reaches a stable release.
Add a before-and-after benchmark. The maintainer needs one table that shows the gain, to report it.
apps/hocuspocus.server/scripts/bench-prisma-bytea.ts, so both runs use the same code. Run it on Prisma 6.19.3, then on 7.10.1, on the same machine and fixtures.history.watchread block on the same head; the cgroup fetch peak for the 10,521,216 B digest pair; and the load and save time of a small, typical document.Both rulings on this issue are now made. It is unblocked.
HMarzban commentedon Oct 25, 2026
Built and committed on local main. Awaits the maintainer's final push.
Remaining gate: the
(build): backdeploy, then a check that migrate deploy, REST, WebSocket and the worker all boot on the amd64 host.chore(hocuspocus): upgrade Prisma to 7.10.1 and give document types o…
fix(hocuspocus): add a per-connection byte budget to history.watch
refactor: cross-review wave-review-w2-7
HMarzban commentedon Nov 3, 2026
Status, 2026-11-03. The Prisma 7.10.1 upgrade shipped in
aef96c59a, with follow-ups ind40b265b7and7ed40b2f0. It is pushed and deployed. Deploy run41608014517passed. Left:ENABLE_SCHEMA_MIGRATIONis on in production (Run the production reads that the 2026-10-23 backend perf plan needs #576).HMarzban commentedon Nov 3, 2026
Result, 2026-11-03. Prisma 7.10.1 shipped in
aef96c59a, with follow-ups ind40b265b7and7ed40b2f0. Deploy run41608014517deployed it on 2026-11-03, and every job passed. The ruled bench table is below.Local measurement setup (arm64 laptop, 2026-10-25).
apps/hocuspocus.server/scripts/bench-prisma-bytea.ts. It uses the realsrc/lib/prisma.tsclient, so it uses the onePrismaPgpool. The measurement code did not change between runs.docker run --memory=1gon linux-arm64.history.watchread, loop block, same head (ms)memory.peak, 1 GiB limit (MiB)memory.peakcannot read abovememory.max. One 6.19.3 sample read exactly 1024 MiB, and the median is 97% of the limit. Read that row as "at the 1 GiB limit".bun audit, 2026-10-25. No advisory namesdeepmerge-tsor any@prisma/*package.@prisma/config7.10.1 pullsdeepmerge-ts8.0.2, so the root[email protected]pin is dropped.fast-uri3.1.7, through theprismaCLI. That version was already in the lock through ESLint, Stylelint and webpack. The runtime client does not load it.Production read (2026-10-25, from #576).
ENABLE_SCHEMA_MIGRATIONis off. It is unset in both WS replicas, REST and the worker, and the code reads unset as false. So cold load does no second decode.Production deploy (run
41608014517, 2026-11-03).The migrate step loaded
prisma.config.tsand applied the two pending migrations.REST, WS and the worker each came up with 2 of 2 replicas healthy.
Each service passed its internal health check.
The same run passed Backend Tests and Backend E2E, on real Postgres and Redis.
Tree check (current
main).git grepfor Prisma 6.19 pins finds nothing.7.10.1.@prisma/clientimport.DocumentMetadatatype is left in hocuspocus.VersionTriggerhas one source,apps/hocuspocus.server/src/types/versionTrigger.ts. The webapp type-imports it.fetchDocumentin the webapp still has no[key: string]: any.Behaviour items.
e2e-store-pipeline.tson real Postgres. It waits for a newDocumentsrow, so a persist still mints one.P2002cede. Their tests intests/integration/documents.test.tsuse a mock Prisma client. So they do not prove Prisma 7 behaviour against a real database.Can close now: yes, after one manual check of Settings search and a slug
P2002cede on the deployed build. The amd64 timings are not measured, and no item asks for them.HMarzban commentedon Nov 9, 2026
Maintainer ruling, 2026-11-09
A local proof on real Postgres covers the slug
P2002cede. No production write is needed to force a slug collision.Local proof, 2026-11-09
The maintainer ruled on 2026-11-09 that a local proof on real Postgres covers the slug
P2002cede. This comment is that proof. It also covers persist and Settings search locally.Setup. Local stack from
make dev-local, onmainatd31ed9033. Postgres isdocsy-postgres-local. REST runs on:4000, and it loads the generated client withclientVersion7.10.1.bunx prisma -vprints 7.10.1 for bothprismaand@prisma/client. The signed-in user is Swarm Actor 1 frompackages/document-swarm. Its session came from the swarm sign-in code. No credentials were typed.1. Persist mints a
Documentsrow.localhost:3000/prisma-proof-1794201086330and typed one line.DocumentMetadatarowMzKA4TqaI0SEAWSkeVY, owned by the actor.Documentsrow landed 10 s later: version 1, triggerwebsocket, 1028 B.2. Settings search returns matches.
GET /api/documents?title=…&ownerId=<actor>&scope=all&sort=updatedAt_desc&limit=20&offset=0, with the actor token.prisma proof 1794201086330returned 200, total 1, and the new pad.prisma & proof & 1794201086330. Acontainsfilter cannot match that text, so only the Postgres full-textsearchfilter matched. SofullTextSearchPostgresstill works on Prisma 7.3. A slug
P2002cede returns.POST /api/documents/MzKA4TqaI0SEAWSkeVY/duplicatecalls went out together in onePromise.all.prisma-proof-1794201086330-copy. The other gotprisma-proof-1794201086330-copy-1794201098842-bcz7l.withUniqueSlugadds that suffix only after a slugP2002. Both rows are inDocumentMetadata.POST /api/documentson the taken slug returned 409CONFLICT, withfield: ["DocumentMetadata_slug_key"]andprismaCode: "P2002".["slug"]. So the Prisma 7 adapter reportsconstraint.indexhere, with nofields. The retry works only becausewithUniqueSlugalso matchesDocumentMetadata_slug_key. A mock client cannot show this.create_documentcall the samewithUniqueSlug(src/lib/slug.ts). They were not run here.4. Tests and tree.
bun testinapps/hocuspocus.server: 1187 pass, 7 skip, 0 fail.bunx prisma migrate status: 19 migrations found, schema up to date.41608014517printedstore pipeline E2E: PASSEDandversions E2E: PASSED.git grepfor 6.19 pins finds nothing.5.
bun audit(Bun 1.4.4, 2026-11-09).deepmerge-tsor any@prisma/*package.[email protected]comes in only through@prisma/[email protected]. The root has nodeepmerge-tspin, so the pin stays dropped.[email protected]advisory is a different package, from jest and next-pwa.Production. Run
41608014517applied two migrations throughprisma.config.ts. REST, WS and the worker each came up with 2 healthy replicas.Production Settings search, 2026-11-09. Read-only, in the maintainer's signed-in browser on docs.plus. Settings → Documents → Search documents:
GET https://prodback.docs.plus/api/documents?…&title=mermaidreturned 200.Status. Every box is met: this comment, the 2026-11-03 result comment, and deploy run
41608014517. Closing as completed.