TypeError: list.filter is not a function.

entire error:
# SERVER_ERROR: 293 | );
294 | let list = [];
295 | const now = Date.now();
296 | if (currentList) {
297 | list = safeJSONParse(currentList) || [];
298 | list = list.filter((session) => session.expiresAt > now);
^
TypeError: list.filter is not a function. (In 'list.filter((session) => session.expiresAt > now)', 'list.filter' is undefined)
at <anonymous> (/Users/medim/Code/auth-server/node_modules/better-auth/dist/shared/better-auth.B5NYxGA3.mjs:298:27)
# SERVER_ERROR: 293 | );
294 | let list = [];
295 | const now = Date.now();
296 | if (currentList) {
297 | list = safeJSONParse(currentList) || [];
298 | list = list.filter((session) => session.expiresAt > now);
^
TypeError: list.filter is not a function. (In 'list.filter((session) => session.expiresAt > now)', 'list.filter' is undefined)
at <anonymous> (/Users/medim/Code/auth-server/node_modules/better-auth/dist/shared/better-auth.B5NYxGA3.mjs:298:27)
Is it bun related? im using bun + hono
3 Replies
Medim
MedimOP4w ago
cc @bekacru seems related to using redis as a secondstorage
Medim
MedimOP4w ago
GitHub
Issue for secondaryStorage with redis · Issue #1641 · better-auth/b...
Is this suited for github? Yes, this is suited for github To Reproduce Create connect redis Login first Log out Login Second Current vs. Expected behavior SERVER_ERROR: [TypeError: list.filter is n...
Toedi
Toedi4w ago
I did also encounter that error yesterday but managed to fix it I am not home currently but let me check when I am back what my solution was But maybe I am also stupid and there really is something wrong I don't exactly remember what the error was yesterday here is my implementation i think the error is just that you need to remove the JSON.stringify from the get function:
secondaryStorage: {
get: async (key) => {
const value = await redis.get(key);
return value ? value : null;
},
set: async (key, value, ttl) => {
if (ttl) {
await redis.set(key, value, "EX", ttl);
} else {
await redis.set(key, value);
}
},
delete: async (key) => {
await redis.del(key);
},
},
secondaryStorage: {
get: async (key) => {
const value = await redis.get(key);
return value ? value : null;
},
set: async (key, value, ttl) => {
if (ttl) {
await redis.set(key, value, "EX", ttl);
} else {
await redis.set(key, value);
}
},
delete: async (key) => {
await redis.del(key);
},
},
i am using ioredis btw but even if you do not that should fix it atleast i am not getting the error anymore

Did you find this page helpful?