question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: db error: FATAL: unexpected response from login query

See original GitHub issue

Bug description

After upgrading to V 4.0.0 using the upgrade page provided I could not run the yarn prisma migrate dev command to push to the database on subapase. The migration works via docker-container, but not on supabase.

The error that occured:

Error: db error: FATAL: unexpected response from login query
   0: migration_core::state::DevDiagnostic
             at migration-engine/core/src/state.rs:250

How to reproduce

Disclaimer: I’m using supabase and it was working on V 3.15.2, this only occurs on V 4.0.0.

  1. Create a database on supabase and use the url connection-string,
  2. Run the yarn prisma generate command.
  3. Run the yarn prisma migrate dev command.
  4. -> Errors, see Prisma Information.

Expected behavior

The migration should successfully run.

Prisma information

This is the schema after the yarn prisma validate command:

generator client {
  provider = "prisma-client-js"
}

generator zod {
  provider              = "zod-prisma"
  output                = "../src/types/zod"
  modelCase             = "PascalCase"
  prismaJsonNullability = "true"
  relationModel         = "true"
  useDecimalJs          = "true"
  modelSuffix           = "Model"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Account {
  id                       String  @id @default(uuid())
  userId                   String
  type                     String
  provider                 String
  providerAccountId        String
  refresh_token            String?
  refresh_token_expires_in Int?
  access_token             String?
  expires_at               Int?
  token_type               String?
  scope                    String?
  id_token                 String?
  session_state            String?
  user                     User    @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model Session {
  id           String   @id @default(uuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
  id               String            @id @default(uuid())
  name             String?
  email            String?           @unique
  emailVerified    DateTime?
  image            String?
  createdAt        DateTime          @default(now())
  updatedAt        DateTime          @updatedAt
  status           UserStatus        @default(Normal)
  deletedAt        DateTime?
  accounts         Account[]
  planParticipants Participant[]
  sessions         Session[]
  teamParticipants TeamParticipant[]
  events           Event[]
  subscribedTo     Subscription[]
}

model Subscription {
  id        String    @id @default(uuid())
  priceId   String
  createdAt DateTime  @default(now())
  deletedAt DateTime?
  updatedAt DateTime  @updatedAt
  price     Price     @relation(fields: [priceId], references: [id])
  users     User[]
}

model Discount {
  id        String    @id @default(uuid())
  name      String    @unique
  value     Float     @default(0.0)
  active    Boolean   @default(false)
  createdAt DateTime  @default(now())
  deletedAt DateTime?
  updatedAt DateTime  @updatedAt
  prices    Price[]
}

model Price {
  id            String         @id @default(uuid())
  createdAt     DateTime       @default(now())
  updatedAt     DateTime       @updatedAt
  valueAnually  Float          @default(0.0)
  valueMonthly  Float          @default(0.0)
  tag           String         @unique
  discountId    String?
  enabled       Boolean        @default(true)
  description   String?
  recommended   Boolean        @default(false)
  deletedAt     DateTime?
  discount      Discount?      @relation(fields: [discountId], references: [id])
  subscriptions Subscription[]
  benefits      Benefit[]
}

model Benefit {
  id          String  @id @default(uuid())
  description String  @unique
  prices      Price[]
}

model VerificationToken {
  identifier String
  token      String   @unique
  expires    DateTime

  @@unique([identifier, token])
}

model Participant {
  userId       String
  planId       String
  addedAt      DateTime                    @default(now())
  updatedAt    DateTime                    @updatedAt
  deletedAt    DateTime?
  inviteStatus ParticipantInvitationStatus @default(INVITE_SENT)
  plan         Plan                        @relation(fields: [planId], references: [id])
  user         User                        @relation(fields: [userId], references: [id])

  @@id([userId, planId])
}

model TeamParticipant {
  userId       String
  teamId       String
  inviteStatus TeamParticipantInvitationStatus @default(INVITE_SENT)
  status       TeamParticipantStatus           @default(MEMBER)
  createdAt    DateTime                        @default(now())
  deletedAt    DateTime?
  updatedAt    DateTime                        @updatedAt
  team         Team                            @relation(fields: [teamId], references: [id], onDelete: Cascade)
  user         User                            @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@id([userId, teamId])
}

model Team {
  id               String            @id @default(uuid())
  name             String
  createdAt        DateTime          @default(now())
  updatedAt        DateTime          @updatedAt
  url              String
  description      String?
  deletedAt        DateTime?
  teamParticipants TeamParticipant[]
  events           Event[]
}

model Event {
  id          String    @id @default(uuid())
  url         String
  title       String
  description String?
  createdAt   DateTime  @default(now())
  updatedAt   DateTime  @updatedAt
  deletedAt   DateTime?
  plans       Plan[]
  team        Team[]
  users       User[]
}

model Plan {
  id           String        @id @default(uuid())
  title        String
  createdAt    DateTime      @default(now())
  deletedAt    DateTime?
  eventId      String?
  updatedAt    DateTime      @updatedAt
  end          DateTime
  start        DateTime
  event        Event?        @relation(fields: [eventId], references: [id], onDelete: Cascade)
  participants Participant[]
  occupations  Occupation[]
}

model Occupation {
  id           String    @id @default(uuid())
  title        String
  createdAt    DateTime  @default(now())
  deletedAt    DateTime?
  updatedAt    DateTime  @updatedAt
  city         String
  postalcode   String
  streetname   String
  streetnumber String
  notes        Note[]
  plans        Plan[]
}

model Note {
  id           String      @id @default(uuid())
  title        String
  content      String      @default("")
  createdAt    DateTime    @default(now())
  deletedAt    DateTime?
  updatedAt    DateTime    @updatedAt
  occupationId String?
  occupation   Occupation? @relation(fields: [occupationId], references: [id])
}

enum UserStatus {
  Normal
  Deleted
  Blocked
  Restricted
  Suspicous
}

enum ParticipantInvitationStatus {
  INVITE_SENT
  CREATOR
  INVITE_PENDING
  INVITE_ACCEPTED
  INVITE_DECLINED
}

enum TeamParticipantInvitationStatus {
  INVITE_SENT
  INVITE_PENDING
  INVITE_ACCEPTED
  INVITE_DECLINED
  CREATOR
}

enum TeamParticipantStatus {
  CREATOR
  MEMBER
  MODERATOR
  VISITOR
}

The DEBUG="*" environment shows these lines (removed personal information)

  prisma:engines  binaries to download libquery-engine, migration-engine, introspection-engine, prisma-fmt +0ms
  prisma:loadEnv  project root found at /home/(...)/package.json +0ms
  prisma:tryLoadEnv  Environment variables loaded from /home/(...)/.env +0ms
  prisma:getConfig  Using CLI Query Engine (Node-API Library) at: /home/(...)/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node +0ms
  prisma:getConfig  Loaded Node-API Library +3ms
  prisma:getConfig  config data retrieved without errors in getConfigNodeAPI +2ms
  prisma:loadEnv  project root found at /home/(...)/package.json +36ms
  prisma:tryLoadEnv  Environment variables loaded from /home/(...)/.env +36ms
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
  prisma:getConfig  Using CLI Query Engine (Node-API Library) at: /home/(...)/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node +31ms
  prisma:getConfig  Loaded Node-API Library +0ms
  prisma:getConfig  config data retrieved without errors in getConfigNodeAPI +2ms
Datasource "db": PostgreSQL database "postgres", schema "public" at "(...)"

  prisma:getDMMF  Using CLI Query Engine (Node-API Library) at: /home/(...)/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node +0ms
  prisma:getDMMF  Loaded Node-API Library +0ms
  prisma:getDMMF  unserialized dmmf result ready +22ms
  prisma:getDMMF  dmmf retrieved without errors in getDmmfNodeAPI +10ms
  prisma:getConfig  Using CLI Query Engine (Node-API Library) at: /home/(...)/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node +90ms
  prisma:getConfig  Loaded Node-API Library +0ms
  prisma:getConfig  config data retrieved without errors in getConfigNodeAPI +2ms
  prisma:getConfig  Using CLI Query Engine (Node-API Library) at: /home/(...)/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node +29ms
  prisma:getConfig  Loaded Node-API Library +0ms
  prisma:getConfig  config data retrieved without errors in getConfigNodeAPI +2ms
  prisma:migrateEngine:rpc  starting migration engine with binary: /home/(...)/node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x +0ms
  prisma:migrateEngine:rpc  SENDING RPC CALL {"id":1,"jsonrpc":"2.0","method":"devDiagnostic","params":{"migrationsDirectoryPath":"/home/(...)/prisma/migrations"}} +7ms
  prisma:migrateEngine:stderr  {"timestamp":"2022-06-30T08:30:14.55293797Z","level":"INFO","fields":{"message":"Starting migration engine RPC server","git_hash":"da41d2bb3406da22087b849f0e911199ba4fbf11"},"target":"migration_engine"} +0ms
  prisma:migrateEngine:rpc  {
  jsonrpc: '2.0',
  error: {
    code: 4466,
    message: 'An error happened. Check the data field for details.',
    data: {
      is_panic: false,
      message: 'db error: FATAL: unexpected response from login query\n' +
        '   0: migration_core::state::DevDiagnostic\n' +
        '             at migration-engine/core/src/state.rs:250',
      backtrace: null
    }
  },
  id: 1
} +2s
Error: Error: db error: FATAL: unexpected response from login query
   0: migration_core::state::DevDiagnostic
             at migration-engine/core/src/state.rs:250

    at Object.<anonymous> (/home/(...)/node_modules/prisma/build/index.js:93489:25)
    at MigrateEngine.handleResponse (/home/(...)/node_modules/prisma/build/index.js:93355:36)
    at LineStream3.<anonymous> (/home/(...)/node_modules/prisma/build/index.js:93447:16)
    at LineStream3.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at LineStream3.Readable.push (node:internal/streams/readable:228:10)
    at LineStream3._pushBuffer (/home/(...)/node_modules/prisma/build/index.js:93235:17)
    at LineStream3._transform (/home/(...)/node_modules/prisma/build/index.js:93229:8)
    at LineStream3.Transform._write (node:internal/streams/transform:184:23)

Environment & setup

  • OS: MX Linux
  • Database: PostgreSQL
  • Node.js version: V16.13.0

Prisma Version

prisma                  : 4.0.0
@prisma/client          : 4.0.0
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine da41d2bb3406da22087b849f0e911199ba4fbf11 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli da41d2bb3406da22087b849f0e911199ba4fbf11 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core da41d2bb3406da22087b849f0e911199ba4fbf11 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt da41d2bb3406da22087b849f0e911199ba4fbf11 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : da41d2bb3406da22087b849f0e911199ba4fbf11
Studio                  : 0.465.0

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
arikarkcommented, Aug 1, 2022

Changing the port to 5432 worked for me.

5reactions
vicentematuscommented, Sep 28, 2022

Changing the port to 5432 worked for me.

Same here, changing to port 5432 worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

closing because: unexpected response from login query ...
Okay, so the issue was that I was trying to log in as one of the admin_users (aakashverma) but I hadn't mentioned them...
Read more >
After resetting database, PgBouncer error unexpected ... - GitLab
After resetting database, PgBouncer error unexpected response from login query · Summary · Steps to reproduce · What is the current bug behavior?...
Read more >
PgBouncer unexcepted response from login query
It works when I login directly on Postgres : psql -h localhost -p 6432 -U admin -W mydb. How to solve this error...
Read more >
pgbouncer/pgbouncer - Gitter
Query for cleaning connection immediately after releasing from client. ... Another thing that looks suspicious is login failed: db=josh user=postgres You ...
Read more >
Database Engine events and errors - SQL Server
For a full list of all errors, query the sys.messages catalog view ... %ls received unexpected database mirroring error response: status %u, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found