redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.27k stars 991 forks source link

[Bug?]: `yarn rw console` hangs for 10 seconds when typing 'db' #8817

Closed kalaracey closed 10 months ago

kalaracey commented 1 year ago

What's not working?

I am going through the tutorial and I have gotten to the part where you begin to use yarn rw console. However, when I type db. (i.e. the beginning of db.post.findMany(...)) the console hangs for five to ten seconds at db. If I backspace from e.g. db.post to the 'd' character, it will similarly hang at db before backspacing through 'b' for five to ten seconds.

Perhaps there is some sort of autocomplete that is blocking the thread.

How do we reproduce the bug?

git clone https://github.com/redwoodjs/redwood-tutorial
cd redwood-tutorial
yarn install
yarn rw prisma migrate dev
yarn rw g secret

Then set up the SESSION_SECRET in .env.

Finally, open yarn rw console and attempt to type db.post.findMany().

What's your environment? (If it applies)

System:
    OS: macOS 13.4.1
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 18.16.1 - /private/var/folders/23/82ghc8m51fx3c774b2v_hcxw0000gn/T/xfs-18826e57/node
    Yarn: 3.3.1 - /private/var/folders/23/82ghc8m51fx3c774b2v_hcxw0000gn/T/xfs-18826e57/yarn
  Databases:
    SQLite: 3.39.5 - /usr/bin/sqlite3
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 16.5.1
  npmPackages:
    @redwoodjs/auth-dbauth-setup: 5.0.0 => 5.0.0 
    @redwoodjs/core: 5.0.0 => 5.0.0

Are you interested in working on this?

Josh-Walker-GM commented 1 year ago

Hey @kalaracey thanks for opening the issue! I can reproduce this behaviour on our test project so it's definitely happening.

Looking at the git history it looks like this command hasn't had much attention for a long time. I wasn't on the team when this was created so don't have any specific insight to offer at the moment. I can do my best to try and help you out if there's anything specific you come across.

A little notice since you said you'd be interested in working on this - which is awesome btw! The team is trying to focus on a few important milestones for our next epoch so we might not be able to be as responsive to this issue as we would like to be. I'll still try to make sure we get back to you though!

dustinsgoodman commented 1 year ago

I've been running into this. Sharing some debug info I found today - if you paste something that goes past the "db", the console doesn't hang, e.g. db.. Seems like it's an issue with how the repl is interpreting the prisma client accessed through db.

cyberious commented 12 months ago

Additionally, when you open a console, as long as you do not start with db it does not freeze. It seems like some eager fetching off all possible Prisma objects in the DB or waiting on a promise that may never come.

> var posts = db.post.findMany()
undefined
> posts
[
  {
    id: 1,
    title: 'Welcome to the blog!',
    body: "I'm baby single- origin coffee kickstarter lo - fi paleo skateboard.Tumblr hashtag austin whatever DIY plaid knausgaard fanny pack messenger bag blog next level woke.Ethical bitters fixie freegan,helvetica pitchfork 90's tbh chillwave mustache godard subway tile ramps art party. Hammock sustainable twee yr bushwick disrupt unicorn, before they sold out direct trade chicharrones etsy polaroid hoodie. Gentrify offal hoodie fingerstache.",
    createdAt: 2023-10-14T23:29:54.403Z
  },
  {
    id: 2,
    title: 'A little more about me',
    body: "Raclette shoreditch before they sold out lyft. Ethical bicycle rights meh prism twee. Tote bag ennui vice, slow-carb taiyaki crucifix whatever you probably haven't heard of them jianbing raw denim DIY hot chicken. Chillwave blog succulents freegan synth af ramps poutine wayfarers yr seitan roof party squid. Jianbing flexitarian gentrify hexagon portland single-origin coffee raclette gluten-free. Coloring book cloud bread street art kitsch lumbersexual af distillery ethical ugh thundercats roof party poke chillwave. 90's palo santo green juice subway tile, prism viral butcher selvage etsy pitchfork sriracha tumeric bushwick.",
    createdAt: 2023-10-14T23:29:54.407Z
  },
  {
    id: 3,
    title: 'What is the meaning of life?',
    body: 'Meh waistcoat succulents umami asymmetrical, hoodie post-ironic paleo chillwave tote bag. Trust fund kitsch waistcoat vape, cray offal gochujang food truck cloud bread enamel pin forage. Roof party chambray ugh occupy fam stumptown. Dreamcatcher tousled snackwave, typewriter lyft unicorn pabst portland blue bottle locavore squid PBR&B tattooed.',
    createdAt: 2023-10-14T23:29:54.411Z
  }
]
>

Additionally, even using await in front of db the query works with absolutely zero hang.

beardo01 commented 11 months ago

I am also seeing this, however it doesn't seem to resolve itself even after waiting 10 seconds. Pasting directly into the terminal works and prefixing with await also works.

Tobbe commented 11 months ago

The console isn't getting much use, so we likely won't get to investigating this anytime soon. But please keep commenting and/or reacting to posts to indicate interest in this issue to keep it on our radar ✈️

ymc9 commented 10 months ago

It should be caused by this one: https://github.com/prisma/prisma/issues/18292

Mind if I make a PR @Tobbe ?

Tobbe commented 10 months ago

@ymc9 Please do! 👍

ymc9 commented 10 months ago

@ymc9 Please do! 👍

Sure. Here you go 😄: https://github.com/redwoodjs/redwood/pull/9623