Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATABASE_URL is baked in Dataproxy client proxy.js #11458

Closed
pfried opened this issue Jan 28, 2022 · 2 comments
Closed

DATABASE_URL is baked in Dataproxy client proxy.js #11458

pfried opened this issue Jan 28, 2022 · 2 comments
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: data proxy
Milestone

Comments

@pfried
Copy link

pfried commented Jan 28, 2022

Bug description

When using previewFeatures = ["dataProxy"] the connection string is baked into the client when running prisma generate.

There is no way to either set it via environment variable nor passing it to the client on instantiation.

How to reproduce

Checkout example from my Example Code based on the Prisma Starter and run yarn install

  1. Set environment variable to some invalid connection string: DATABASE_URL=INVALID
  2. Run yarn run generate
  3. Change either env variable to valid string or pass valid url to Constructor in script.ts
  4. Run yarn run dev

Will fail with P5002

Happy path is above setting env to valid path before client generation.

Expected behavior

Can be passed in like

const prisma = new PrismaClient({
  log: ["query", "error"],
  datasources: {
    db: {
      url: "prisma://aws-eu-central-1.prisma-data.com/?api_key=ABC"
    }
  }
})

or in .env file with

DATABASE_URL=prisma://aws-eu-central-1.prisma-data.com/api_key=ABC

Prisma information

prisma 3.7.0 or ^3.8.1

Environment & setup

  • OS: Windows
  • Database: Postgres via Dataproxy
  • Node.js version: 16.10.0

Prisma Version

prisma 3.7.0 or ^3.8.1

(tested with those versions)

@pfried pfried added the kind/bug A reported bug. label Jan 28, 2022
@janpio janpio added team/client Issue for team Client. team/pdp Issue for team Prisma Data Platform. topic: data proxy labels Jan 28, 2022
@pfried
Copy link
Author

pfried commented Jan 28, 2022

Related to #10187

Obviously if the related issue had more context I could have found about that earlier

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/scale and removed team/pdp Issue for team Prisma Data Platform. labels Jan 28, 2022
@millsp millsp added tech/typescript Issue for tech TypeScript. size/s labels May 6, 2022
@millsp millsp self-assigned this Jun 1, 2022
@millsp millsp added this to the 3.15.0 milestone Jun 1, 2022
@millsp millsp closed this as completed Jun 7, 2022
@millsp
Copy link
Member

millsp commented Jun 7, 2022

Hey @pfried. We have released some changes a few minutes ago in prisma@3.15.0. tl;dr;

  • Instead of PRISMA_CLIENT_ENGINE_TYPE, use prisma generate --data-proxy to enable the Data Proxy
  • import { PrismaClient } from '@prisma/client/edge' for a Workers-compatible Prisma Client
  • Please be aware that .env aren't bundled into the generated Prisma Client any longer (see docs)
  • You can also remove any package location aliasing from your build scripts
  • Warnings around eval are now also fixed

Thanks, and your feedback is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: data proxy
Projects
None yet
Development

No branches or pull requests

3 participants