Timeout when deploying to Cloudflare Workers with Better Auth when using getSession

Hiya 👋 I'm deploying a React Router v7 application to Cloudflare Workers, using Better Auth and Drizzle ORM. My issue is that the Worker fails validation due to exceeding a startup limit. This seems to happen mostly when then code below is present, as without it, the application seems to deploy successfully.
const session = await auth.api.getSession({
headers: request.headers,
});
const session = await auth.api.getSession({
headers: request.headers,
});
Any suggestions/points on how to go about resolving this would be very welcome. Thank you!
Your Worker failed validation because it exceeded startup limits.

To ensure fast responses, there are constraints on Worker startup, such as how much CPU it can
use, or how long it can take. Your Worker has hit one of these startup limits. Try reducing the
amount of work done during startup (outside the event handler), either by removing code or
relocating it inside the event handler.
Your Worker failed validation because it exceeded startup limits.

To ensure fast responses, there are constraints on Worker startup, such as how much CPU it can
use, or how long it can take. Your Worker has hit one of these startup limits. Try reducing the
amount of work done during startup (outside the event handler), either by removing code or
relocating it inside the event handler.
2 Replies
KiNFiSH
KiNFiSH•2mo ago
hmm i dont know exactly about your config but may be can you try at least doing some kind of caching like cookieCache for session data
andreaselia
andreaseliaOP•2mo ago
I have no idea what caused it, but it just stopped happening 🤯

Did you find this page helpful?