My getCurrentUser query began receiving an undefinedsession in the 2nd parameter after upgrading to Blitz 0.40.0-canary.7. The starter app and docs seem to indicate that session shouldn't be undefined.
I cannot reproduce this on my local machine with blitz dev or blitz start, but it is occurring reliably in production on Cloud Run. It seems to also be occurring in Vercel, based on a very similar report in this thread on the Blitz.js Discord.
I use a Dockerfile to deploy to Cloud Run which I have summarized below. I have also included the relevant sections of my blitz.config.ts file, Ctx type, and getCurrentUser queries.
react-dom.development.js?61bb:66 Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
react_devtools_backend.js:2850 Error: Cannot read property 'userId' of undefined
useBaseQuery.js?e893:91 Uncaught Error: Cannot read property 'userId' of undefined
Paste all relevant code snippets here:
getCurrentUser.ts
import { Ctx } from "blitz";
import prisma from "db";
export default async (_query: unknown, { session }: Ctx) => {
// console.log(session) prints undefined
// The line below throws an error in production, because session is undefined.
if (session.userId) {
return prisma.user.findUnique({
select: {
email: true,
id: true,
role: true,
},
where: {
id: session.userId,
},
});
}
return null;
};
Use a Dockerfile to build and deploy to Cloud Run. This issue also seems to occur on Vercel, as noted above.
Execute the getCurrentUser query using the useCurrentUser hook. These are included in the Blitz.js starter app.
You will be redirected to the 500 error page with the following message: "Cannot read property 'userId' of undefined.". In addition, the logs pasted above should be reproduced in the browser console and Blitz CLI.
What is the problem?
My
getCurrentUser
query began receiving anundefined
session
in the 2nd parameter after upgrading to Blitz 0.40.0-canary.7. The starter app and docs seem to indicate thatsession
shouldn't beundefined
.I cannot reproduce this on my local machine with
blitz dev
orblitz start
, but it is occurring reliably in production on Cloud Run. It seems to also be occurring in Vercel, based on a very similar report in this thread on the Blitz.js Discord.I use a Dockerfile to deploy to Cloud Run which I have summarized below. I have also included the relevant sections of my blitz.config.ts file,
Ctx
type, andgetCurrentUser
queries.Paste all your error logs here:
Blitz CLI
Browser Console
Paste all relevant code snippets here:
getCurrentUser.ts
types.ts
Dockerfile
blitz.config.js
What are detailed steps to reproduce this?
getCurrentUser
query using theuseCurrentUser
hook. These are included in the Blitz.js starter app.Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
No response