Upgrading from rw 3.x to 4.0.0

Hello RW community,

I am trying to upgrade my rewood environment from 3.x to 4.0. The upgrade went smooth without any issue. However, when I run yarn rw dev, I see errors on the server side as below

api | 🚨 TypeError Info
api | 
api | {}
api |  
api | 🥞 Error Stack
api | 
api | TypeError: Cannot read properties of undefined (reading 'toUpperCase')
api |     at onRequest (/Home/project_sample/node_modules/graphql-yoga/cjs/plugins/useCORS.js:111:32)
api |     at YogaServer.getResponse (/Home/project_sample/node_modules/graphql-yoga/cjs/server.js:289:23)
api |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
api |     at async YogaServer.handle (/Home/project_sample/node_modules/graphql-yoga/cjs/server.js:41:34)
api |     at async handlerFn (/Home/project_sample/node_modules/@redwoodjs/graphql-server/dist/functions/graphql.js:178:24)
api |     at async execFn (/Home/project_sample/node_modules/@redwoodjs/graphql-server/dist/functions/graphql.js:233:16)
api |     at async requestHandler (/Home/project_sample/node_modules/@redwoodjs/api-server/dist/requestHandlers/awsLambdaFastify.js:72:30)
api | 
api | 22:07:28 🚨 Cannot read properties of undefined (reading 'get') 
api | 
api | 🚨 TypeError Info
api | 
api | {}
api |  
api | 🥞 Error Stack
api | 
api | TypeError: Cannot read properties of undefined (reading 'get')
api |     at getMediaTypesForRequestInOrder (/Home/project_sample/node_modules/graphql-yoga/cjs/plugins/resultProcessor/accept.js:5:38)
api |     at onResultProcess (/Home/project_sample/node_modules/graphql-yoga/cjs/plugins/useResultProcessor.js:39:86)
api |     at processResult (/Home/project_sample/node_modules/graphql-yoga/cjs/process-request.js:10:15)
api |     at YogaServer.getResponse (/Home/project_sample/node_modules/graphql-yoga/cjs/server.js:349:71)
api |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
api |     at async YogaServer.handle (/Home/project_sample/node_modules/graphql-yoga/cjs/server.js:41:34)
api |     at async handlerFn (/Home/project_sample/node_modules/@redwoodjs/graphql-server/dist/functions/graphql.js:178:24)
api |     at async execFn (/Home/project_sample/node_modules/@redwoodjs/graphql-server/dist/functions/graphql.js:233:16)
api |     at async requestHandler (/Home/project_sample/node_modules/@redwoodjs/api-server/dist/requestHandlers/awsLambdaFastify.js:72:30)

It seems to me api/src/functions/graphql.js is not working properly. It looks like below

import { authDecoder } from '@redwoodjs/auth-dbauth-api'
import { createGraphQLHandler } from '@redwoodjs/graphql-server'

import directives from 'src/directives/**/*.{js,ts}'
import sdls from 'src/graphql/**/*.sdl.{js,ts}'
import services from 'src/services/**/*.{js,ts}'

import { getCurrentUser } from 'src/lib/auth'
import { db } from 'src/lib/db'
import { logger } from 'src/lib/logger'

export const handler = createGraphQLHandler({
  authDecoder,
  getCurrentUser,
  // cors: {
  //   origin: '*',
  //   credentials: true,
  // },
  loggerConfig: { logger, options: { requestId: true } },
  directives,
  sdls,
  services,
  armorConfig: { maxDepth: { n: 6 } },
  onException: () => {
    // Disconnect from your database with an unhandled exception.
    db.$disconnect()
  },
})

The frontend loads without issue but I am struggling getting the backend running.

Hi. This was fixed in release 4.2.1.

Please see Discord

And also

And the original issue [Bug?]: GraphQL Requests Fail with RedwoodJS v.4.2.0 · Issue #7691 · redwoodjs/redwood · GitHub

Upgrading to this release should fix it.

Thanks @dthyresson
That fixed it on the localhost and my app works as expected. Next time I probably have to take a closer look at subsequent release notes.
On the prod, when I deploy to netlify, it is complaining about @babel/core as requirement for redwood core. Is this something related to recent changes?

10:34:12 AM: $ yarn rw deploy netlify
10:34:13 AM: /opt/build/repo/.pnp.cjs:48299
10:34:13 AM:       Error.captureStackTrace(firstError);
10:34:13 AM:             ^
10:34:13 AM: Error: @redwoodjs/cli tried to access @babel/core, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
10:34:13 AM: Required package: @babel/core
10:34:13 AM: Required by: @redwoodjs/cli@npm:5.0.6 (via /opt/buildhome/.yarn_cache/@redwoodjs-cli-npm-5.0.6-88b5349192-e9ba736f5b.zip/node_modules/@redwoodjs/cli/dist/lib/)
10:34:13 AM: Require stack:
10:34:13 AM: - /opt/buildhome/.yarn_cache/@redwoodjs-cli-npm-5.0.6-88b5349192-e9ba736f5b.zip/node_modules/@redwoodjs/cli/dist/lib/index.js
10:34:13 AM: - /opt/buildhome/.yarn_cache/@redwoodjs-cli-npm-5.0.6-88b5349192-e9ba736f5b.zip/node_modules/@redwoodjs/cli/dist/lib/project.js
10:34:13 AM: - /opt/buildhome/.yarn_cache/@redwoodjs-cli-npm-5.0.6-88b5349192-e9ba736f5b.zip/node_modules/@redwoodjs/cli/dist/commands/build.js
10:34:13 AM: - /opt/buildhome/.yarn_cache/@redwoodjs-cli-npm-5.0.6-88b5349192-e9ba736f5b.zip/node_modules/@redwoodjs/cli/dist/index.js
10:34:13 AM: - /opt/buildhome/.yarn_cache/@redwoodjs-cli-npm-5.0.6-88b5349192-e9ba736f5b.zip/node_modules/@redwoodjs/cli/package.json
10:34:13 AM:     at Function.require$$0.Module._resolveFilename (/opt/build/repo/.pnp.cjs:48299:13)
10:34:13 AM:     at Function.require$$0.Module._load (/opt/build/repo/.pnp.cjs:48149:42)
10:34:13 AM:     at Module.require (node:internal/modules/cjs/loader:1098:19)
10:34:13 AM:     at require (node:internal/modules/cjs/helpers:108:18)
10:34:13 AM:     at Object.<anonymous> (/opt/buildhome/.yarn_cache/@redwoodjs-cli-npm-5.0.6-88b5349192-e9ba736f5b.zip/node_modules/@redwoodjs/cli/dist/lib/index.js:29:37)
10:34:13 AM:     at Module._compile (node:internal/modules/cjs/loader:1196:14)
10:34:13 AM:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
10:34:13 AM:     at Object.require$$0.Module._extensions..js (/opt/build/repo/.pnp.cjs:48343:33)
10:34:13 AM:     at Module.load (node:internal/modules/cjs/loader:1074:32)
10:34:13 AM:     at Function.require$$0.Module._load (/opt/build/repo/.pnp.cjs:48180:14)

I didn’t really change my package.json
It is what it used to be before this upgrade.

{
  "private": true,
  "workspaces": {
    "packages": [
      "api",
      "web",
      "packages/*"
    ]
  },
  "devDependencies": {
    "@redwoodjs/auth-dbauth-setup": "5.0.6",
    "@redwoodjs/core": "5.0.6"
  },
  "dependencies": {
    "@redwoodjs/core": "^5.0.6"
  },
  "eslintConfig": {
    "extends": "@redwoodjs/eslint-config",
    "root": true
  },
  "engines": {
    "node": ">=16.x <=18.x",
    "yarn": ">=1.15"
  },
  "prisma": {
    "seed": "yarn rw exec seed"
  },
  "packageManager": "yarn@3.5.1"
}

When I updated my yaml to the latest for some reason .yarn/releases got added to the gitignore file. It should have beeen !.yarn/releases
Now the problem is resolved.

2 Likes