Redwood v7.0.0 Upgrade Guide

I’m currently upgrading from 6.X to 7.1.3 and am running into an issue with running the studio in a github action (we run the studio for our UI tests in CI)

Basically, when trying to run the studio in CI, it gives the following error:

PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime “debian-openssl-1.1.x”.

This happened because Prisma Client was generated for “darwin-arm64”, but the actual deployment required “debian-openssl-1.1.x”.

For context, I am doing local development on a Mac and this is only a problem for running the studio – not running the actual app. It suggests adding “debian-openssl-1.1.x” to the binaryTargets in schema.prisma but I don’t have access to this because it’s in a dependency’s prisma.schema (or at least, I think I don’t)

Has anyone run into this? My question is obviously how to fix this. But more specifically, I’m wondering at what point the prisma client is generated for the studio? It strikes me that the engine could be hard coded somewhere that has been committed but I’ve yet to be able to find it.

Thanks for the help in advance!

1 Like

Yeah I’ve had this same issue and I think a few others have mentioned something similar above. From my research, it seems like the fix is in this PR of @redwoodjs/studio, which has already been merged to the main branch. The problem is that there has not been a new tag/build of that package that includes that change. @Tobbe mentioned above that he was going to work on getting that done, but I haven’t seen any new tags come through.

2 Likes

You will find the engine in /node_modules/@redwoodjs/studio/api/db/client/

To get rw studio working locally on Mac,
Redwood version 7.3.0 (but these steps worked on RW 7.1.3)

  1. I delete the engine at /node_modules/@redwoodjs/studio/api/db/client/

  2. I then copy in the correct engine (for me)
    from
    /node_modules/.prisma/client/libquery_engine-darwin.dylib.node
    to
    /node_modules/@redwoodjs/studio/api/db/client/

  3. At this point yarn rw studio works for me.

  4. But… i still do not get the graphs

  5. I had to install the open telemetyry
    yarn rw exp setup-opentelemetry

6 And…make a fix suggested elsewhere to
node_modules/@redwoodjs/studio/api/dist/functions/otel-trace/otel-trace.js
changing two lines
from
startTimeNano: convertLongToBigInt(span.startTimeUnixNano),
endTimeNano: convertLongToBigInt(span.endTimeUnixNano),
to
startTimeNano: span.startTimeUnixNano,
endTimeNano: span.endTimeUnixNano,

  1. Now starting the dev server (yarn rw dev) then studio (yarn rw studio) works for me.
2 Likes

Hey all :wave:

We just released version 11.4.0 of studio. This contains some important bug fixes which should address the problems discussed here. If you could try it out and confirm everything now works that would be awesome!

2 Likes

Hi there,

Now that it seems like the studio issue maybe worked out, I gave upgrading another go and am running into an issue with global context. I am using supabase auth and my context is empty on any graphql call (and I am definitely logged in, currentUser query returns properly). Is there anything that I need to do to populate the context object?

For context, when I tried upgrading previously, this was not an issue (7.1.2) but on 7.4.3 this started happening.


1 Like

Thanks for the information on this one! The context should be populated automatically - there should be no need to change context-related code when you’re upgrading your project.

It would be particularly helpful if you could confirm this issue happens not at v7.0.0 but in some minor or patch version afterward? Is this happening for you locally during rw dev / rw serve or is it when deployed?

I’ve updated this github issue [Bug?]: Upgrading to 7.1.3 - "You don't have permission to do that." · Issue #10223 · redwoodjs/redwood · GitHub but currently, I have been unable to reproduce this error. Until a reproduction is available I can’t move this forward :slightly_frowning_face:

I think hasRole is broken or the implementation of it? isAuthenticated, logOut and currentUser works though. I submitted this discord thread:

I tested this on a fresh install, here are my steps (discord has images):

  1. yarn create redwood-app --ts ./testApp
  2. Added User and Role models to schema
  3. yarn rw setup auth dbAuth
  4. yarn rw prisma migrate dev to my local sqlite db (I didn’t bother to set up my postgres production db–the issue is the same either way)
  5. yarn rw g dbAuth to create the login flow
  6. yarn rw g page Home
  7. added a privateset to my routes to force the login to access home
  8. added a new user and gave him admin role using prisma studio
  9. added console logs to the HomePage for hasRole
  10. still returns false

My hunch is that the models in my schema are set up as many-to-many between User and Role but the tutorial mentions to use roles as a string field. I remember in older versions of Redwood this worked fine, did v7 drop support for a Role model in favor of string? So I tried changing the models and making the roles field on User a string. Same outcome, hasRole is still returning false.

EDIT: The solution is how you return the user from getCurrentUser. You have to specify roles as well, see here: Role-Based Access Control (RBAC) | RedwoodJS Docs

@jamesj Just to confirm – you got it working, right? Is there anything we can do to make this easier/better?

After upgrading to 7.5.0 and later 7.6.2 we experienced a problem (only on Windows) where the hot reloading in yarn rw dev was not working and we were getting the following errors:

Error after hot reloading api/
api | 16:25:40 🌲 incoming request POST xxx /graphql
api | 16:25:40 🌲 request completed 100ms
api | 16:25:40 🌲 request completed 106ms
api | 16:25:46 🌲 incoming request POST xxx /graphql
api | 16:25:46 🌲 request completed 291ms
api | 16:25:46 🌲 incoming request POST xxx /graphql
api | 16:25:46 🌲 incoming request POST xxx /graphql
api | 16:25:47 🌲 request completed 80ms
api | Took 28940 ms
api | 16:25:47 🌲 incoming request POST xxx /graphql
api | 16:25:47 🌲 incoming request POST xxx /graphql
api | 16:25:47 🌲 incoming request POST xxx /graphql
api | 16:25:47 🌲 request completed 270ms
api | Starting inspector on 127.0.0.1:18911 failed: address already in use
api | 16:25:47 🌲 request completed 146ms
api | 16:25:47 🌲 request completed 177ms
api | 16:25:47 🌲 request completed 317ms
api | Took 28389 ms
api | Starting inspector on 127.0.0.1:18911 failed: address already in use
api | Importing Server Functions... 
api | ...Done importing in 1 ms
api | Importing Server Functions... 
api | ...Done importing in 1 ms
api | 16:25:55 🌲 incoming request POST xxx /graphql
api | 16:25:55 🌲 request completed 239ms
api | GraphQL Yoga Server endpoint at graphql
api | GraphQL Yoga Server Health Check endpoint at graphql/health
api | GraphQL Yoga Server Readiness endpoint at graphql/readiness
api | GraphQL Yoga Server endpoint at graphql
api | GraphQL Yoga Server Health Check endpoint at graphql/health
api | GraphQL Yoga Server Readiness endpoint at graphql/readiness
api | node:net:1898
api |     const ex = new UVExceptionWithHostPort(err, 'listen', address, port);
api |                ^
api |
api | Error: listen EADDRINUSE: address already in use :::8911
api |     at Server.setupListenHandle [as _listen2] (node:net:1898:16)
api |     at listenInCluster (node:net:1946:12)
api |     at doListen (node:net:2116:7)
api |     at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
api |   code: 'EADDRINUSE',
api |   errno: -4091,
api |   syscall: 'listen',
api |   address: '::',
api |   port: 8911
api | }
api |
api | Node.js v20.13.1
api | node:net:1898
api |     const ex = new UVExceptionWithHostPort(err, 'listen', address, port);
api |                ^
api |
api | Error: listen EADDRINUSE: address already in use :::8911
api |     at Server.setupListenHandle [as _listen2] (node:net:1898:16)
api |     at listenInCluster (node:net:1946:12)
api |     at doListen (node:net:2116:7)
api |     at process.processTicksAndRejections (node:internal/process/task_queues:83:21) {
api |   code: 'EADDRINUSE',
api |   errno: -4091,
api |   syscall: 'listen',
api |   address: '::',
api |   port: 8911
api | }
api |
api | Node.js v20.13.1
api | 16:26:39 🌲 incoming request POST xxx /graphql
api | 16:26:40 🌲 request completed 211ms
api | 16:26:40 🌲 incoming request POST xxx /graphql
api | 16:26:40 🌲 incoming request POST xxx /graphql
api | 16:26:41 🌲 request completed 109ms

This seems to occur almost every time that I switch branches or discard changes through Git. The weird thing is that the api still works, but sometimes it doesn’t reload new code. E.g. when switching branches like in the log below in the log below new queries (SDLs, services and frontend) were added in the branch I changed over to, but they didn’t get picked up:

Hot reloading unable to recognize new code
api | 16:28:32 🚨 graphql-server Cannot query field "products" on type "Query". [Suggestion hidden]?
api | 16:28:32 🌲 request completed 7ms
api | 16:28:32 🌲 incoming request POST xxx /graphql
api | 16:28:32 🚨 graphql-server Cannot query field "tags" on type "Query". [Suggestion hidden]?
api | 16:28:32 🌲 request completed 2ms
api | 16:28:32 🌲 incoming request POST xxx /graphql
api | 16:28:32 🚨 graphql-server Cannot query field "reviews" on type "Query". [Suggestion hidden]?
api | 16:28:32 🌲 request completed 2ms

I tried deleting build files and node_modules, and reinstalling but it made no difference.

I have tried to backtrack our changes from when we upgraded from version 6 to 7. Here we swapped server.config.js for the new server.ts. We didn’t have anything custom in there so we didn’t make any changes after running yarn rw setup server-file as described in this upgrade guide. But it did not seem to cause the issues.

I’ve been busy with my job, but I have some time now so I’ll write up a change to contribute to the Docs. The solution was ultimately simple enough, but it’s not documented with a structure of user->role->permissions objects. Instead, the RBAC documentation uses strings and if anyone else wants to create their own permission system within dbAuth they will likely experience this issue as well. Thank you!

I keep getting the UNAUTHENTICATED response in my graphiQL when I perform authenticated queries.

I have the studio.graphiql.authImpersonation config set in my redwood.toml file.

Is the authImpersonation user meant to be an actual user existing in my db or any sample can work? Either way my queries still fail. I’m on Studio version 11.4.0

Settings instructions for 7.7.0 seem to not be working, it works if I set it like this:

"tailwindCSS.classAttributes": [
    "class",
    "className",
    "activeClassName",
    "errorClassName"
  ]

Hi. Yes, the impersonation must map to a real user for dbAuth. Other impersonation may be different because it depends on what the currentUser function does with the decoded token or cookie.

For dbAuth since the user is fetched from the database then that user record must exist.

7.7.0 also breaks linting in one of our projects

❯ yarn rw lint

=============

WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.2.0

YOUR TYPESCRIPT VERSION: 5.4.5

Please only submit bug reports when using the officially supported version.

=============

Oops! Something went wrong! :(

ESLint: 8.57.0

TypeError: Error while loading rule 'react/jsx-no-target-blank': `[[GeneratorState]]` is not present on `O`
Occurred while linting /home/userName/dev/projectName/projectName/web/src/App.tsx
    at Object.assert (/home/userName/dev/projectName/projectName/node_modules/eslint-plugin-react/node_modules/es-iterator-helpers/node_modules/internal-slot/index.js:18:10)
    at GeneratorStart (/home/userName/dev/projectName/projectName/node_modules/eslint-plugin-react/node_modules/es-iterator-helpers/aos/GeneratorStart.js:12:7)
    at CreateIteratorFromClosure (/home/userName/dev/projectName/projectName/node_modules/eslint-plugin-react/node_modules/es-iterator-helpers/aos/CreateIteratorFromClosure.js:42:2)
    at Array Iterator.map (/home/userName/dev/projectName/projectName/node_modules/eslint-plugin-react/node_modules/es-iterator-helpers/Iterator.prototype.map/implementation.js:71:15)
    at Object.getLinkComponents (/home/userName/dev/projectName/projectName/node_modules/eslint-plugin-react/lib/util/linkComponents.js:38:18)
    at Object.create (/home/userName/dev/projectName/projectName/node_modules/eslint-plugin-react/lib/rules/jsx-no-target-blank.js:180:47)
    at createRuleListeners (/home/userName/dev/projectName/projectName/node_modules/eslint/lib/linter/linter.js:895:21)
    at /home/userName/dev/projectName/projectName/node_modules/eslint/lib/linter/linter.js:1066:110
    at Array.forEach (<anonymous>)
    at runRules (/home/userName/dev/projectName/projectName/node_modules/eslint/lib/linter/linter.js:1003:34)

Yea, so I use a real user for my auth impersonation but I still get unauthorized

Thanks for the issue report @razzeee

Would you like to create a PR for fixing it?

If you find time, please do, I might only find time after friday. Would also need to check the tests etc as it seems to be used in multiple places Code search results · GitHub and I’m unsure if that old behavior is always wrong.

Seems to be solveable by regenerating the yarn.lock

I fixed the Tailwind setting issue earlier today:

Hey @lars ,

i am running in the same problems. Were you able to solve it?