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

Seeding seems to swallow errors #9286

Closed
matthewmueller opened this issue Sep 15, 2021 · 0 comments · Fixed by #9387
Closed

Seeding seems to swallow errors #9286

matthewmueller opened this issue Sep 15, 2021 · 0 comments · Fixed by #9387
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: prisma db seed CLI: prisma db seed
Milestone

Comments

@matthewmueller
Copy link
Contributor

Bug description

Seeding seems to swallow runtime errors

How to reproduce

Given the following in prisma/seed.ts

import { PrismaClient, Color } from "@prisma/client"
import * as fs from "fs/promises"
const prisma = new PrismaClient()

async function main() {
  await prisma.$connect()
  const files = await fs.readdir("./zzzzz")   // doesn't exist
  console.log(files)
  }

main()
  .catch(console.error)
  .finally(() => prisma.$disconnect())

Note that the directory doesn't exist. I have a package.json with:

{
  "prisma": {
    "seed": "ts-node prisma/seed.ts"
  }
}

When I run npx prisma db seed:

npx prisma db seed    
Environment variables loaded from .env
Running seed command `ts-node prisma/seed.ts` ...

🌱  The seed command has been executed.

However when I run the command directly:

ts-node prisma/seed.ts
[Error: ENOENT: no such file or directory, scandir './zzzzz'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'scandir',
  path: './zzzzz'
}

Expected behavior

I'd expect to see the error from prisma seed and for it to fail

Prisma information

Environment & setup

  • OS: Mac OS
  • Database: Postgres
  • Node.js version: v14.16.0

Prisma Version

Environment variables loaded from .env
prisma                  : 3.0.2
@prisma/client          : 3.0.2
Current platform        : darwin
Query Engine (Node-API) : libquery-engine 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine        : migration-engine-cli 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine    : introspection-core 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary           : prisma-fmt 2452cc6313d52b8b9a96999ac0e974d0aedf88db (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash    : 2452cc6313d52b8b9a96999ac0e974d0aedf88db
Studio                  : 0.423.0
@matthewmueller matthewmueller added kind/bug A reported bug. process/candidate team/schema Issue for team Schema. labels Sep 15, 2021
@pantharshit00 pantharshit00 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Sep 16, 2021
@janpio janpio added the topic: prisma db seed CLI: prisma db seed label Sep 16, 2021
@tomhoule tomhoule added this to the 3.2.0 milestone Sep 22, 2021
@Jolg42 Jolg42 self-assigned this Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: prisma db seed CLI: prisma db seed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants