Skip to content

feat(prisma)!: resolve PrismaEnvironment on every request - #3122

Merged
sam-goodwin merged 1 commit into
mainfrom
feat/prisma-token-effect
Nov 7, 2026
Merged

sam-goodwin merged 1 commit into
mainfrom
feat/prisma-token-effect

Conversation

@sam-goodwin

Copy link
Copy Markdown
Member

PrismaEnvironment now holds an Effect, like CloudflareEnvironment, FlyEnvironment and RailwayEnvironment. Alchemy runs it on every Management API request, so a host can supply a token that refreshes during a deploy, such as a prisma login session.

Layer.succeed(
  Prisma.PrismaEnvironment,
  Effect.map(cli.getAccessToken, (serviceToken) => ({
    type: "serviceToken" as const,
    serviceToken,
    source: { type: "stored" as const },
    baseUrl: "https://api.prisma.io",
  })),
);

Breaking: code that provides or reads PrismaEnvironment directly changes shape.

-Layer.succeed(Prisma.PrismaEnvironment, { type: "serviceToken", serviceToken, source, baseUrl })
+Layer.succeed(Prisma.PrismaEnvironment, Effect.succeed({ type: "serviceToken", serviceToken, source, baseUrl }))

-const env = yield* Prisma.PrismaEnvironment;
+const env = yield* Prisma.PrismaEnvironment.current;

Prisma.providers() and Prisma.managementApi() are unchanged.

This also bumps submodules/distilled to distilled main, which includes alchemy-run/distilled#1076 (Credentials.apiToken is now optional). Log streams open their own WebSocket, so they can't let a transport add the header. When Credentials has no token they now fail with a ConfigError instead of connecting without auth.

This is the alternative to #3101: with a per-request token the host doesn't need to authenticate through HttpClient, and every request, the log socket included, carries the current token.

@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

pnpm install https://pkg.alchemy.run/alchemy/pr:3122:10fb6e8
@alchemy.run (30)
pnpm install https://pkg.alchemy.run/@alchemy.run/better-auth/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/git/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/drizzle/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/acme/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/archil/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/axiom/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/doppler/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/infisical/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/turso/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/daytona/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/planetscale/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/neon/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/prisma/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/hetzner/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/railway/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/fly/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/github/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/stripe/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/cloudflare/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/gcp/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/aws/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/domain/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/kubernetes/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/docker/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/redis/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/sql/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/cloudflare-runtime/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/node-utils/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@alchemy.run/pkg/pr:3122:10fb6e8
Transitive Dependencies (22)
pnpm install https://pkg.alchemy.run/@distilled.cloud/aws/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/acme/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/archil/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/core/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/axiom/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/doppler/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/infisical/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/turso/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/daytona/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/planetscale/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/neon/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/s3/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/prisma/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/hetzner/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/railway/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/fly-io/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/github/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/stripe/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/aws4signer/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/cloudflare/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/iceberg/pr:3122:10fb6e8
pnpm install https://pkg.alchemy.run/@distilled.cloud/gcp/pr:3122:10fb6e8

Published Nov 7, 2026, 3:18 AM UTC. Expires Nov 14, 2026, 3:18 AM UTC, extended while this pull request is open.

@sam-goodwin
sam-goodwin merged commit ab9a138 into main Nov 7, 2026
7 checks passed
@sam-goodwin
sam-goodwin deleted the feat/prisma-token-effect branch November 7, 2026 06:36
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