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

Error in prisma results in unhandled promise rejection #3945

Closed
steebchen opened this issue Oct 15, 2020 · 0 comments · Fixed by #4137
Closed

Error in prisma results in unhandled promise rejection #3945

steebchen opened this issue Oct 15, 2020 · 0 comments · Fixed by #4137
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: error topic: prisma-client

Comments

@steebchen
Copy link
Contributor

steebchen commented Oct 15, 2020

When there's an invalid value provided to prisma at runtime, it will result in an error, but that error doesn't contain a useful stack trace.

import "source-map-support/register"
import { prisma } from "./prisma/prisma"

prisma.$connect().catch((err) => {
	console.log(err)
	process.exit(1)
}).then(() => {
	return prisma.user.findOne({ where: { id: null as any as string }})
}).then(() => {
	process.exit(0)
})
❯ ts-node app.ts
(node:46264) UnhandledPromiseRejectionWarning: Error:
Invalid `prisma.user.findOne()` invocation in
/Users/prisma/projects/redacted/backend/app.ts:10:33

6    // process.exit(1)
7 }).then(() => {
8    return prisma.user.findOne({ where: { id: null as any as string }})
→ 9 }).then(() => {
where: {
id: null
~~~~
}
})

Argument id for where.id must not be null. Please use undefined instead.


    at Qh.validate (/Users/prisma/projects/redacted/backend/node_modules/@prisma/client/runtime/src/runtime/query.ts:280:19)
    at t._executeRequest (/Users/prisma/projects/redacted/backend/node_modules/@prisma/client/runtime/src/runtime/getPrismaClient.ts:883:16)
    at /Users/prisma/projects/redacted/backend/node_modules/@prisma/client/runtime/src/runtime/getPrismaClient.ts:787:16
    at AsyncResource.runInAsyncScope (async_hooks.js:186:9)
    at t._request (/Users/prisma/projects/redacted/backend/node_modules/@prisma/client/runtime/src/runtime/getPrismaClient.ts:786:25)
    at Object.then (/Users/prisma/projects/redacted/backend/node_modules/@prisma/client/runtime/src/runtime/getPrismaClient.ts:948:39)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:46264) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:46264) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Since this is an unhandled promise rejection, no error is returned and you can't catch it, which is probably the same reason for not getting a useful stacktrace about where the error originated from.

Environment variables loaded from prisma/.env
@prisma/cli          : 2.9.0
@prisma/client       : 2.9.0
Current platform     : darwin
Query Engine         : query-engine 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/query-engine-darwin)
Migration Engine     : migration-engine-cli 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary        : prisma-fmt 369b3694b7edb869fad14827a33ad3f3f49bbc20 (at node_modules/@prisma/cli/prisma-fmt-darwin)
Studio               : 0.296.0
Preview Features     : atomicNumberOperations
✨  Done in 2.53s.
@steebchen steebchen changed the title Error in prisma is showing a useless stacktrace Error in prisma results in unhandled promise rejection Oct 15, 2020
@pantharshit00 pantharshit00 added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. labels Oct 16, 2020
@janpio janpio added this to the Backlog 2.11.0 milestone Oct 28, 2020
timsuchanek added a commit that referenced this issue Nov 3, 2020
Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
Jolg42 added a commit that referenced this issue Nov 4, 2020
* master: (25 commits)
  chore: cleanup tests
  chore: update snapshots
  fix: only generate .env path if present
  fix: improve warning
  fix(client): stack trace with source-map-support. Closes #3945 (#4137)
  feat(client, sdk, cli): env loading rewrite (#4142)
  ci: increase health check retries for db GH Actions
  fix(deps): update dependency undici to v2.1.1 (#4135)
  chore(deps): update devdependencies (non-major)
  fix(deps): update engines to v2.11.1-4-1d5919363a85847350c3f517da9babd9bcaca792 (#4131)
  ci: try fix for flaky client GH actions
  chore(deps): update studio to v0.307.0 (#4128)
  fix(client): remove package.json in custom output paths (#4130)
  feat: stabilize transaction & connectOrCreate (#4129)
  fix: print getConfig warnings (#4124)
  fix(cli): Ignore all errors that occur when opening Studio in a browser (#4119)
  chore: update renovate for Studio [skip ci]
  Bump Studio [skip ci]
  chore(cli): preinstall throw on node < 10 (#4118)
  chore: cleanup jest config (#4120)
  ...

# Conflicts:
#	src/packages/migrate/src/bin.ts
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. tech/typescript Issue for tech TypeScript. topic: error topic: prisma-client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants