Ryan Nieuwoudt
Ryan Nieuwoudt
BABetter Auth
Created by Ryan Nieuwoudt on 3/2/2025 in #bug-reports
Auto Cleanup for expired verification data - fails on D1 (also sqlite?)
Using better-auth on Cloudflare D1. Since updating to better-auth 1.2, authentication fails with errors as follows:
(log) Query: delete from "auth_verifications" where "auth_verifications"."expiresAt" = ? -- params: ["2025-03-02T14:23:00.936Z"]
(error) # SERVER_ERROR: Error: D1_TYPE_ERROR: Type 'object' not supported for value 'Sun Mar 02 2025 14:23:00 GMT+0000 (Coordinated Universal Time)'
(log) Query: delete from "auth_verifications" where "auth_verifications"."expiresAt" = ? -- params: ["2025-03-02T14:23:00.936Z"]
(error) # SERVER_ERROR: Error: D1_TYPE_ERROR: Type 'object' not supported for value 'Sun Mar 02 2025 14:23:00 GMT+0000 (Coordinated Universal Time)'
This can be reproduced on Cloudflare D1, when using the proposed fix in this PR which fixes insertions into verifications, but not the cleanups. It may also affect sqlite directly, when using the kysely-adapter instead of the drizzle-adapter. Essentially, the field values in where clauses are not being transformed as supported by Cloudflare D1. Workaround exists, when instantiating betterAuth:
verification: {
disableCleanup: true,
},
verification: {
disableCleanup: true,
},
Expected behaviour would be auto-cleanup working for Cloudflare D1 without error.
5 replies