Error: Something went wrong

Invalid `db.teamMember.findMany()` invocation in
api | /Users/bogdan/Documents/proiecte/epfa/api/src/services/teamMembers/teamMembers.ts:6:24
api | 
api |   3 import { db } from 'src/lib/db'
api |   4 
api |   5 export const teamMembers = () => {
api | → 6   return db.teamMember.findMany(
api |   The table `main.TeamMember` does not exist in the current database.

Running yarn rw dev will build but app will not work. Will have the error from above in console and the UI will show Something went wrong.

I’m using rw version 0.46. did a fresh typescript project.
The only way i made it work was deleting node modules from api and web. But doing this all the time seems strange. :slight_smile:

I don’t have a home page for the app but have some pages build in /team, /members, etc.

Router structure is

      <Route path="/login" page={LoginPage} name="login" />
      <Route path="/signup" page={SignupPage} name="signup" />
      <Route path="/forgot-password" page={ForgotPasswordPage} name="forgotPassword" />
      <Route path="/reset-password" page={ResetPasswordPage} name="resetPassword" />
      <Private unauthenticated="login">
        <Set wrap={TeamMembersLayout}>
          <Route path="/admin/team-members/new" page={AdminTeamMemberNewTeamMemberPage} name="adminNewTeamMember" />
          <Route path="/admin/team-members/{id:Int}/edit" page={AdminTeamMemberEditTeamMemberPage} name="adminEditTeamMember" />
          <Route path="/admin/team-members/{id:Int}" page={AdminTeamMemberTeamMemberPage} name="adminTeamMember" />
          <Route path="/admin/team-members" page={AdminTeamMemberTeamMembersPage} name="adminTeamMembers" />
      <Route path="/team" page={TeamPage} name="team" />
      <Route notfound page={NotFoundPage} />

UI error

Hi @bogdan2510, welcome to the Redwood community!

I think you probably just have to run a prisma migrate. yarn rw prisma migrate dev should do the trick.

This happens when your prisma schema and your db, or your prisma client, go out of sync.

running yarn rw prisma migrate dev does not fix the issue. @danny

Hi I ran into this yesterday and “somehow” two Prisma clients exist in my app. And the one in api seemed confused.

I deleted my node_modules in my api directory and then yarned, migrated and also generated the Prisma client.

My seeds and app ran better after that.

Did that but the problem persists. what commands did you run? I want to make sure we did the same thing.

I can’t recall exactly but the core issue was multiple Prisma clients and there was one in the api directory node_modules and also maybe in the root node_modules.

I did delete both those directories and then ran commands:

yarn rw prisma migrate
yarn rw prisma generate
yarn rw g types

I think— sorry I cannot recall exact.

But the error pointed me to where the offending client was

Something in this lines i did before posting this(as mentioned in the post body). The issue persists after vscode restart and the only way i can make it work is by doing it al over again. :slight_smile: I guess this is not the intended flow. :slight_smile:

So I just came across this… I’ll try and reproduce, but the root cause of the issue is that prisma seems to generate another client inside api/node_modules/.prisma - so when you’re running the api server it’s picking the client from the nested api/node_modules rather than the root ./node_modules/.prisma

I found that deleting the generated client in the api folder fixes it:

rm -rf api/node_modules/.prisma

Any idea how this keeps happening for you @bogdan2510 - like a series of steps to help me reproduce reliably?

For me the steps are:

  1. create fresh typescript project;
  2. start the project by running yarn rw dev. keep the project running;
  3. create a model
  4. run migrations yarn rw prisma migrate dev
  5. create scaffold for the model created above

At this point the error is in full effect and i need to delete node_modules from api, web to make it work again.

P.S: i will try more stuff to make sure this steps will always produce the error.

1 Like

FWIW I found a stray .prisma/ in web/node_modules yesterday in one of my projects. So it’s not only api/ that’s affected

Seems like the issue is still present on version 0.48.0.
Steps to reproduce:

  1. create fresh rw app using version 0.47.0. (i had the app created when i posted this bug. The version was 0.47.0)
  2. update to version 0.48.0
  3. run the app. At this point all is good.
  4. close the app and start it again. Now the bug is in full efect.

Thanks for the confirmation @bogdan2510 - I’ve identified this as a Prisma + yarn workspaces issue, I will follow up again with the prisma team shortly, but I’m sure they’re working hard to resolve.

Prisma issue here:

Two potentials solutions you have right now:

a) Upgrade your project to the yarn 3 (which we added preview support for in v0.48.0) - release notes here:

If this works for you, I would say this is the preferred workaround right now.


b) Downgrade prisma version to 3.8.1 (the last known working version, without issues) - by adding resolutions to both api/package.json and the root package.json

  "resolutions": {
    "@prisma/client": "3.8.1",
    "@prisma/cli": "3.8.1",
    "@prisma/sdk": "3.8.1"

But you’ll have to remember to take these out once they’ve fixed :slight_smile:

1 Like

i create prisma schema and SDL but i have error like this:

i add this in api/package.json but not work :
“resolutions”: {
@prisma/client”: “3.8.1”,
@prisma/cli”: “3.8.1”,
@prisma/sdk”: “3.8.1”

something went wrong

Hi @bobwatcherx the masked error message of “Something went wrong” is appropriate for the response, but you should see the original error on the api development log.

There is a fix for the error info not appearing in the log here Unreasonably Opaque GraphQL Errors (non-Error thrown as error) - #8 by dthyresson and a patch is being released. This should give you more guidance to what has happened.

You may also want to turn on Prisma logging to see the any SQL errors that may have occurred. For more info, see: Logger | RedwoodJS Docs