Custom Session running twice on GET /api/auth/get-session

I'm trying out custom session to return some additonal team fields on the repsonse to use on the client side and i noticed(sinces its making a call to the db and i have the logger on) it's running the custom Session method twice for every single call to GET /api/auth/get-session is this to be expected or have i done something funky in my config
my custom session looks like the following:
customSession(async ({ user, session }) => {
            if (config.dev) console.log('custom session is running');
            const userTeams = await getUserTeam(DrizzlePgPool(config.db), user.id);
            // console.log('userTeams:', userTeams, session);
            return {
                user,
                teams: userTeams,
                session
            }
        })

on my logs you can see the request being called once but customsession is running twice?
[wrangler:inf] GET /api/auth/get-session 200 OK (54ms)
custom session is running
Query: select "team_member"."role", "team_member"."team_id", "team"."name" from "team_member" left join "team" on "team_member"."team_id" = "team"."id" where "team_member"."user_id" = $1 -- params: ["USERID
"]
custom session is running
Query: select "team_member"."role", "team_member"."team_id", "team"."name" from "team_member" left join "team" on "team_member"."team_id" = "team"."id" where "team_member"."user_id" = $1 -- params: ["USERID"]
[wrangler:inf] GET /static/apple-touch-icon.png 200 OK (41ms)
[wrangler:inf] GET /static/favicon-32x32.png 200 OK (40
ms)
Solution
OK i had to do something funky i literaly had to copy over your customSessionClientPlugin

and make this change
async (ctx) => {
                    const session = await getSessionFromCtx(ctx);
                    if (!session) {
                        return ctx.json(null);
                    }
                    if (!ctx.request?.url) {
                        console.log('skipping runnig session function')
                        return { user: session.user, session: session.session };
                    }

                    if (ctx.request?.url?.includes(route)) {
                        console.log('custom session is running correctly');

                    }
                    const fnResult = await fn(session as any);
                    return ctx.json(fnResult);

                    // return ctx;
                }


Left everything else the same this is working now not sure where teh extra call was coiming from might be something on the hono end but its working regardless now...
Was this page helpful?