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.

Unclear rust error: called `Option::unwrap()` on a `None` value

See original GitHub issue

When a relation is null, Prisma is throwing an unclear error:

  engine stdout { timestamp: 'Feb 21 14:24:17.391',
  level: 'ERROR',
  target: 'prisma',
  fields:
   { message: 'PANIC',
     reason: 'called `Option::unwrap()` on a `None` value',
     file:
      '/rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/macros/mod.rs',
     line: 15,
     column: 40 } } +21ms
  engine { error:
  engine    { Error: socket hang up
  engine        at createHangUpError (_http_client.js:323:15)
  engine        at Socket.socketOnEnd (_http_client.js:426:23)
  engine        at Socket.emit (events.js:203:15)
  engine        at endReadableNT (_stream_readable.js:1145:12)
  engine        at process._tickCallback (internal/process/next_tick.js:63:19) code: 'ECONNRESET' } } +1ms
  prisma-client Error: PANIC
  prisma-client     at currentRequestPromise.then.catch.e (/Users/prisma/prisma/prisma-examples/typescript/graphql-sdl-first/node_modules/@prisma/client/runtime/index.js:1:16175)
  prisma-client     at process._tickCallback (internal/process/next_tick.js:68:7) +8ms
Error: 
Invalid `prisma.posts.findOne()` invocation in
/Users/prisma/prisma/prisma-examples/typescript/graphql-sdl-first/src/schema.ts:71:18

   67 return ctx.prisma.post.findMany({
   68   where: {
   69     OR: [
   70       { title: { contains: args.searchString } },
→  71       PANIC
    at PrismaClientFetcher.request (/Users/prisma/prisma/prisma-examples/typescript/graphql-sdl-first/node_modules/@prisma/client/index.js:89:17)
    at process._tickCallback (internal/process/next_tick.js:68:7)

related code (don’t mind the stack trace above – it’s wrong due to the JS madness)

author: (parent, args, ctx: Context) => {
  return ctx.prisma.post
    .findOne({
      where: { id: parent.id },
    })
    .author() // error happens here
},

reproduction available at https://github.com/prisma/prisma-examples/tree/prisma2/typescript/graphql-sdl-first:

git clone https://github.com/prisma/prisma-examples
cd prisma-examples/typescript/graphql-sdl-first
yarn install
yarn prisma2 generate
yarn dev &
pid=$!

sleep 10

curl 'http://localhost:4000/' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: http://localhost:4000' --data-binary '{"query":"query {\n  feed {\n    id\n    content\n    author {\n      id\n      name\n      email\n    }\n  }\n}"}' --compressed

kill "$pid"

related: https://github.com/prisma/prisma-examples/issues/1484

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
tomhoulecommented, Feb 25, 2020

I confirm I couldn’t reproduce this with the latest alpha as well 👍

1reaction
pantharshit00commented, Feb 25, 2020

Similar error message, in a completely different place: #1692

This unrelated to #1692. Option::unwrap() on a None value is a common rust panic is Option type is used quite a lot in Rust.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Panicked at 'called `Option::unwrap()` on a `None` value ...
I find this part of the error message obtuse: RUST_BACKTRACE=1 refers to an environment variable. Set the environment variable RUST_BACKTRACE to ...
Read more >
Called `Option::unwrap()` on a `None` value - Editors and IDEs
I get this macro expansion warning with matklad.rust-analyzer v 0.2.776 with VSCode but not with cargo builld.
Read more >
libpnet error: thread 'main' panicked at 'called `Option::unwrap ...
It seems that adding tcp_header.set_options() results in a panic. thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ...
Read more >
stylo: panicked at 'called `Option::unwrap()` on a `None` value'
Example bugs: toggling class name on an element does not restyle the element; background-color property does not support hsl() values. Specifications covered:.
Read more >
Why Rust should only have provided `expect` for turning ...
I see the unwrap function called a lot, especially in example code, ... errors, in Err (or its equivalent in the Option world,...
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