blitz
blitz copied to clipboard
useAuthenticatedBlitzContext fails on vercel
What is the problem?
using useAuthenticatedBlitzContext in a server component layout creates this error, as well as getBlitzContext
Paste all your error logs here:
Error: Cannot find module 'debug'
Require stack:
- /var/task/.next/server/app/(main)/page.js
- /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require.js
- /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js
- /var/task/___next_launcher.cjs
- /opt/node-bridge/chunk-N3ULQXIM.js
- /opt/node-bridge/chunk-5UAC7W5H.js
- /opt/node-bridge/vercel-tla.js
- /var/task/___vc/__launcher/__launcher.js
Paste all relevant code snippets here:
import { useAuthenticatedBlitzContext } from '@/blitz-server';
export default async function MainLayout({
children,
}: {
children: React.ReactNode;
}) {
await useAuthenticatedBlitzContext({
redirectTo: '/login',
});
return <div>{children}</div>;
}
What are detailed steps to reproduce this?
Run blitz -v
and paste the output here:
Blitz version: 2.0.5 (local)
Linux 5.15 | linux-x64 | Node: v20.11.0
Package manager: pnpm
System:
OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (24) x64 AMD Ryzen 9 7900X 12-Core Processor
Memory: 11.05 GB / 15.19 GB
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
Yarn: Not Found
npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
npmPackages:
@blitzjs/auth: 2.0.5 => 2.0.5
@blitzjs/next: 2.0.5 => 2.0.5
@blitzjs/rpc: 2.0.5 => 2.0.5
@prisma/client: ^5.8.1 => 5.10.2
blitz: 2.0.5 => 2.0.5
next: 14.1.3 => 14.1.3
prisma: ^5.8.1 => 5.10.2
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: 5.4.2 => 5.4.2
After searching I found the differences needed to achieve the error. I have made a public repo for you to check, download it make a .env with SESSION_SECRET_KEY and a mysql db url, and run it with pnpm vercel deploy. In the last commit it errors as I said, in the commit before that, named "works" it works. Repo: https://github.com/cfragkos/blitz-test TLDR: Next 14 instead of 13 breaks it
With https://github.com/blitz-js/blitz/pull/4311, next 14 works for me. Maybe you can try different deploy platform like flightcontrol or railway
@siddhsuresh @flybayer any updates on this?
@cfragkos does version 2.0.6 fix this for you?
no
@siddhsuresh any updates?
@cfragkos no, unfortunately we are unable to reproduce locally. This is a Vercel specific problem, and because they have lack of documentation, we are unable to investigate.
I recommend opening a Vercel support issue.
@timneutkens Can you take a look at this. Repro: https://github.com/gengjiawen/blitzjs-demo