lucia-auth / lucia

Authentication, simple and clean
https://lucia-auth.com
MIT License
9.19k stars 467 forks source link

[Bug]: TypeError: Cannot destructure property 'id' of 'raw' as it is null. #1701

Open MahirAlam opened 4 days ago

MahirAlam commented 4 days ago

Package

​@lucia-auth/session-drizzle

Describe the bug

It is so sudden!

I checked everything all (everything was working). then, I pushed the code to github and then the production build showed an error (the error started showing in production when I changed the username and name by updating the DB) and when I ran the dev server same Kind of error was showing!

The error!

 ⨯ node_modules\@lucia-auth\adapter-drizzle\dist\drivers\postgresql.js (72:13) @ transformIntoDatabaseUser
 ⨯ TypeError: Cannot destructure property 'id' of 'raw' as it is null.
    at async $$ACTION_0 (./src/libs/auth.ts:60:20)
digest: "1922790224"
  70 | }
  71 | function transformIntoDatabaseUser(raw) {
> 72 |     const { id, ...attributes } = raw;
     |             ^
  73 |     return {
  74 |         id,
  75 |         attributes
 ⨯ node_modules\@lucia-auth\adapter-drizzle\dist\drivers\postgresql.js (72:13) @ transformIntoDatabaseUser
 ⨯ TypeError: Cannot destructure property 'id' of 'raw' as it is null.
    at async $$ACTION_0 (./src/libs/auth.ts:60:20)
digest: "1922790224"
  70 | }
  71 | function transformIntoDatabaseUser(raw) {
> 72 |     const { id, ...attributes } = raw;
     |             ^
  73 |     return {
  74 |         id,
  75 |         attributes

I also sometime get this message

tP [Error]: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options
    at Proxy.callable (E:\tera-tok\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:36:13125)
    at eval (webpack-internal:///(rsc)/./src/libs/auth.ts:62:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AuthLayout (webpack-internal:///(rsc)/./src/app/(auth)/layout.tsx:16:22)
tP [Error]: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options
    at Proxy.callable (E:\tera-tok\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:36:13125)
    at eval (webpack-internal:///(rsc)/./src/libs/auth.ts:62:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AuthLayout (webpack-internal:///(rsc)/./src/app/(auth)/layout.tsx:16:22)
I always ignore it.

I tried deleting the DB and tried loging in again e.t.c. but nothing worked!