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

PANIC in /root/.cargo/git/checkouts/rust-postgres-dc0fca9be721a90f/8a61d46/postgres-types/src/lib.rs:762:18expected array type #7638

Closed
jacktan165 opened this issue Jun 14, 2021 · 2 comments

Comments

@jacktan165
Copy link

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v14.16.1
OS darwin
Prisma Client 2.21.2
Query Engine query-engine e421996c87d5f3c8f7eeadd502d4ad402c89464d
Database undefined

Query

mutation {
  createOneRecipe(data: {
    name: "X"
    link: "X"
    imageUrl: "X"
    prepTime: "X"
    servings: "X"
    numSaved: 5
    categories: [FAST_FOOD]
    allergies: []
    diets: []
    cuisines: []
    periods: []
    recommended: false
    ingredients: {
      connectOrCreate: [
        {
          create: {
            quantity: 5
            ingredient: {
              connect: {
                name: "X"
              }
            }
          }
          where: {
            recipeLink_ingredientName: {
              recipeLink: "X"
              ingredientName: "X"
            }
          }
        }
      ]
    }
  }) {
    id
    link
    name
    prepTime
    servings
    numSaved
    categories
    allergies
    cuisines
    diets
    periods
    userEmail
    imageUrl
    recommended
    ingredients {
      quantity
      recipeLink
      ingredientName
      ingredient {
        id
        name
        currency
        price
        unit
        userEmail
      }
    }
  }
}

Logs

prisma:engine   }
  prisma:engine }  
  prisma:engine {
  prisma:engine   error: Error: connect ECONNREFUSED 127.0.0.1:49245
  prisma:engine       at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  prisma:engine     errno: -61,
  prisma:engine     code: 'ECONNREFUSED',
  prisma:engine     syscall: 'connect',
  prisma:engine     address: '127.0.0.1',
  prisma:engine     port: 49245
  prisma:engine   }
  prisma:engine }  
  prisma:engine {
  prisma:engine   error: Error: connect ECONNREFUSED 127.0.0.1:49245
  prisma:engine       at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  prisma:engine     errno: -61,
  prisma:engine     code: 'ECONNREFUSED',
  prisma:engine     syscall: 'connect',
  prisma:engine     address: '127.0.0.1',
  prisma:engine     port: 49245
  prisma:engine   }
  prisma:engine }  
  prisma:engine stdout  Starting a postgresql pool with 9 connections.  
  prisma:engine stdout  Started http server on http://127.0.0.1:49286  
  prisma:engine Search for Query Engine in /Users/jacktan/Documents/git/foodbudget/node_modules/.prisma/client  
  plusX Execution permissions of /Users/jacktan/Documents/git/foodbudget/node_modules/.prisma/client/query-engine-darwin are fine  
  prisma:engine Client Version: 2.21.2  
  prisma:engine Engine Version: query-engine e421996c87d5f3c8f7eeadd502d4ad402c89464d  
  prisma:engine Active provider: postgresql  
  prisma:engine stdout  PANIC in /root/.cargo/git/checkouts/rust-postgres-dc0fca9be721a90f/8a61d46/postgres-types/src/lib.rs:762:18
expected array type  
  prisma:engine {
  prisma:engine   error: SocketError: other side closed
  prisma:engine       at Socket.onSocketEnd (/Users/jacktan/Documents/git/foodbudget/node_modules/@prisma/client/runtime/index.js:25205:24)
  prisma:engine       at Socket.emit (events.js:327:22)
  prisma:engine       at Socket.EventEmitter.emit (domain.js:467:12)
  prisma:engine       at endReadableNT (internal/streams/readable.js:1327:12)
  prisma:engine       at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  prisma:engine     code: 'UND_ERR_SOCKET'
  prisma:engine   }
  prisma:engine }  
  prisma:engine {
  prisma:engine   error: SocketError: other side closed
  prisma:engine       at Socket.onSocketEnd (/Users/jacktan/Documents/git/foodbudget/node_modules/@prisma/client/runtime/index.js:25205:24)
  prisma:engine       at Socket.emit (events.js:327:22)
  prisma:engine       at Socket.EventEmitter.emit (domain.js:467:12)
  prisma:engine       at endReadableNT (internal/streams/readable.js:1327:12)
  prisma:engine       at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  prisma:engine     code: 'UND_ERR_SOCKET'
  prisma:engine   }
  prisma:engine }  
  prisma:engine {
  prisma:engine   error: SocketError: other side closed
  prisma:engine       at Socket.onSocketEnd (/Users/jacktan/Documents/git/foodbudget/node_modules/@prisma/client/runtime/index.js:25205:24)
  prisma:engine       at Socket.emit (events.js:327:22)
  prisma:engine       at Socket.EventEmitter.emit (domain.js:467:12)
  prisma:engine       at endReadableNT (internal/streams/readable.js:1327:12)
  prisma:engine       at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  prisma:engine     code: 'UND_ERR_SOCKET'
  prisma:engine   }
  prisma:engine }  

When attempting to migrate after modifying enum values, I get this error.

Error: Database error
Error querying the database: db error: ERROR: column "allergies" cannot be cast automatically to type "Allergy"[]
HINT: You might need to specify "USING allergies::"Allergy"[]".
   0: migration_core::api::ApplyMigrations
             at migration-engine/core/src/api.rs:73

Here is the SQL migration file:

/*
  Warnings:

  - The values [SULPHITE,TREE_NUT] on the enum `Allergy` will be removed. If these variants are still used in the database, this will fail.
  - Changed the column `allergies` on the `Recipe` table from a scalar field to a list field. If there are non-null values in that column, this step will fail.
  - Changed the column `allergies` on the `User` table from a scalar field to a list field. If there are non-null values in that column, this step will fail.

*/
-- AlterEnum
BEGIN;
CREATE TYPE "Allergy_new" AS ENUM ('GLUTEN', 'PEANUT', 'SEAFOOD', 'SESAME', 'SOY', 'DAIRY', 'EGG', 'WHEAT');
ALTER TABLE "Recipe" ALTER COLUMN "allergies" TYPE "Allergy_new" USING ("allergies"::text::"Allergy_new");
ALTER TABLE "User" ALTER COLUMN "allergies" TYPE "Allergy_new" USING ("allergies"::text::"Allergy_new");
ALTER TYPE "Allergy" RENAME TO "Allergy_old";
ALTER TYPE "Allergy_new" RENAME TO "Allergy";
DROP TYPE "Allergy_old";
COMMIT;

-- AlterTable
ALTER TABLE "Recipe" ALTER COLUMN "allergies" SET DATA TYPE "Allergy"[];

-- AlterTable
ALTER TABLE "User" ALTER COLUMN "allergies" SET DATA TYPE "Allergy"[];

I change this enum:

Prisma

enum Allergy {
  GLUTEN
  PEANUT
  SEAFOOD
  SESAME
  SOY
  DAIRY
  EGG
  SULPHITE
  TREE_NUT
  WHEAT
}

to

enum Allergy {
  GLUTEN
  PEANUT
  SEAFOOD
  SESAME
  SOY
  DAIRY
  EGG
  WHEAT
}

It has something to do with modifying the enum values, because I did a similar migration before this, by changing the enum value, and I get the same error. This is the error I got when I attempt to call prisma.

Invalid `prisma.recipe.create()` invocation:


  PANIC in /root/.cargo/git/checkouts/rust-postgres-dc0fca9be721a90f/8a61d46/postgres-types/src/lib.rs:762:18
expected array type
@jacktan165
Copy link
Author

jacktan165 commented Jun 17, 2021

This issue is still ongoing. I have reset my database and tried everything to make this work.
If I initiate the model for the first time, it's fine. When I modify the enum I get the error.

I can confirm this issue comes from Prisma itself. I'm not familiar with Rust at all, but is there some way I can do anything to escalate this? Because this is a huge bug issue.

@jacktan165
Copy link
Author

Closing this issue in favor of #7712

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

No branches or pull requests

1 participant