Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Lucia using Postgres via Drizzle - Date issue #1666

Open
cliftonc opened this issue Aug 17, 2024 · 0 comments
Open

[Bug]: Lucia using Postgres via Drizzle - Date issue #1666

cliftonc opened this issue Aug 17, 2024 · 0 comments
Labels
bug Something ain't right...

Comments

@cliftonc
Copy link

Package

lucia

Describe the bug

I am migrating from SQLite to Postgres, using Drizzle. When I use the same table structure I get an error in Lucia:

TypeError: date2.getTime is not a function
       at isWithinExpirationDate (file:///Users/cliftonc/work/fintune/node_modules/lucia/node_modules/oslo/dist/index.js:34:30)
       at Lucia.validateSession (file:///Users/cliftonc/work/fintune/node_modules/lucia/dist/core.js:70:14)

This is because in your postgres adapter you assume the date being returned from postgres is a date:

The reason this works in your tests is you use the native postgres.js, but Drizzle (for some reason) introduced a breaking change: https://github.com/drizzle-team/drizzle-orm/releases/tag/0.30.0

So my suggestion would be to check if the field is a Date, and if not try to convert it. I've made a small PR but no issue if you would prefer another path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something ain't right...
Projects
None yet
Development

No branches or pull requests

1 participant