Repository navigation
fix(compute): load a Temporal polyfill in the database templates - #8631
Merged
Merged
Conversation
The hono, nextjs and tanstack-start templates store createdAt and updatedAt with the pg/timestamptz-temporal@1 codec, which needs a global Temporal. Node.js 22 and Bun 1.3.14 have none, so db:seed and any query that reads a row failed with RUNTIME.TEMPORAL_UNAVAILABLE. Load temporal-polyfill/global in src/prisma/db.ts and pin temporal-polyfill 1.0.5. tanstack-start's index route called toISOString() on createdAt, which is a Temporal.Instant; use toString(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Resolve the bun.lock conflicts in the hono, nextjs and tanstack-start templates: keep the temporal-polyfill entries and drop terminal-size, which latest no longer depends on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
@coderabbitai review |
Contributor
|
Contributor
Author
|
@coderabbitai full review |
Contributor
✅ Action performedFull review finished. |
Contributor
Author
|
@coderabbitai approve |
Contributor
✅ Action performedComments resolved and changes approved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Loads
temporal-polyfill/globalinsrc/prisma/db.tsof the three database templates (compute/hono,compute/nextjs,compute/tanstack-start), sodb:seedand the routes work once the database has rows.compute/personal-sitehas no database and is not touched.Why
createdAtandupdatedAtuse thepg/timestamptz-temporal@1codec (src/prisma/contract.json), which reads and writesTemporal.Instantvalues through the globalTemporal. Node.js 22 and Bun 1.3.14 have none:typeof globalThis.Temporalisundefinedon Node.js 22.23.3 and Bun 1.3.14.test.yamlruns Node.js 22.22.1 and Bun 1.3.14, and each template'sprisma-deploy.ymlsets Node.js 22.23.2.On
latest, with the templates' own pins (@prisma/orm-postgres8.0.0-rc.8):bun run db:seedexits 1 withRUNTIME.TEMPORAL_UNAVAILABLE: "Mutation default generator 'instantNow' cannot produce a value because this runtime has no global Temporal implementation."GET /api/usersreturns 500 in all three templates, and so doesGET /in hono and tanstack-start. The server log showsRUNTIME.TEMPORAL_UNAVAILABLE. With an empty database the pages render.The ORM docs give this fix for Node.js 22: import the polyfill "before the first query (add
temporal-polyfillas a dependency)".Changes
compute/{hono,nextjs,tanstack-start}/package.json,bun.locktemporal-polyfill1.0.5, pinned exactly like the other dependencies. The lockfiles gaintemporal-polyfill,temporal-spec1.0.1 andtemporal-utils1.0.3npm view temporal-polyfill:latestis 1.0.5, published 2026-09-11. Lockfile hashes matchnpm view <package>@<version> dist.integrity.@prisma/orm-postgres@8.0.0-rc.17declares the peer range^1.0.4compute/{hono,nextjs,tanstack-start}/src/prisma/db.tsimport 'temporal-polyfill/global'afterdotenv/config, before the ORM runtime import. Every route andseed.tsreach the database through this moduleTemporal./globalcovers the ISO 8601 and Gregorian calendars, which is allTemporal.Instantneeds; the ORM docs'/full/globaladds other calendar systemscompute/tanstack-start/src/routes/index.tsxuser.createdAt.toISOString()becomesuser.createdAt.toString()createdAtis aTemporal.Instant, which hastoString()andtoJSON()but notoISOString()(MDN). With the polyfill andtoISOString(),GET /still returns 500.toString()returns an ISO 8601 UTC string such as2026-10-13T13:24:06.322ZWith #8629
This PR is based on
latest, and either PR can merge first. Whichever lands second gets a one-line conflict in each of the threebun.lockfiles, at theterminal-sizeentry: #8629 drops that package, and this PR adds thetemporal-*entries just above it. #8629's lockfiles already holdtemporal-polyfill1.0.5,temporal-spec1.0.1 andtemporal-utils1.0.3 as peers of the ORM, and the workspace entry"temporal-polyfill": "1.0.5"merges without a conflict. Take #8629's side of the conflict (dropterminal-size);bun install --frozen-lockfilethen passes in all three templates. Don't add the workspace line again, or the key is duplicated. The other files merge cleanly.On
latest,db:seedstill fails after this PR, withORM.COLUMN_UNKNOWN(Unknown column "posts" in table "user"):@prisma/orm-postgres8.0.0-rc.8 rejects the nestedpostsinupsert({ create }). #8629 rewritesseed.tswithcreate(). On #8629's branch without this PR,db:seedexits 1 withRUNTIME.TEMPORAL_UNAVAILABLE(checked in tanstack-start). With both, it passes.Verification
Local, Node.js 22.23.3 and Bun 1.3.14.
This branch:
npx vitest run tests/compute.test.ts: 1 test passed. Bundles answered HTTP 500 (hono:ECONNREFUSEDon the placeholderDATABASE_URL), 200 (nextjs), 500 (tanstack-start:jsxDEV is not a functionunder vitest'sNODE_ENV=test, as described in fix(compute): move Composer's config into the composer section of prisma.config.ts #8629), 200 (personal-site). NoRUNTIME.code in the log.bun install --frozen-lockfile,bun run buildandtsc --noEmitpass in hono, nextjs and tanstack-start. The polyfill ends up in each build: in.output/server/_libs(tanstack-start), in the server chunk (nextjs), and as an import of thetemporal-polyfilldependency indist/prisma/db.js(hono).@prisma/dev(the repo's test dependency), afterbun run db:init: a script that callsgetDb()to create a user and a post and read them back fails onlatestwithRUNTIME.TEMPORAL_UNAVAILABLEand passes on this branch in each template;createdAtcomes back as aTemporal.Instant. Then each template'sstartcommand withDATABASE_URLset, with those rows in the database:latest:GET /latest:GET /api/usersGET /GET /api/usersbunx prisma dev module.tswith thelatestpins (prisma8.0.0-rc.12, Composer 0.16.0) brought the stack up, but its service did not answer requests here, even with an empty database. So the Composer path was checked on top of #8629.On top of #8629 (a local merge of this branch into
88ed884, lockfiles resolved as above, not pushed):npx vitest run tests/compute.test.ts: 1 test passed, same bundle statuses as above.bun run build, thenbunx prisma dev module.ts. The service receives onlyCOMPOSER_WEB_PORT,COMPOSER_WEB_ORIGINandCOMPOSER_WEB_DB_URL, sodb.tstakes theservice.load()path. Empty database:GET /200 andGET /api/users[]. Thenbun run db:seedtwice; both runs exit 0. ThenGET /200 (hono's page lists Marie and Alice with 1 post each) andGET /api/users200 with both users and their posts.Sources
Checked 2026-10-13.
dist/errors-DYyzTYzE-39CV_aMo.mjsin@prisma/orm-target-postgres@8.0.0-rc.8, and the runs above.skills/prisma-8/references/contract.mdand thepeerDependenciesinpackage.jsonof@prisma/orm-postgres@8.0.0-rc.17.Temporal.Instantmethods: MDN..github/workflows/test.yamlandcompute/*/.github/workflows/prisma-deploy.ymlonlatest.🤖 Generated with Claude Code
Summary by CodeRabbit