SvelteKit appears to call getSession()
before endpoints and it should be calling them after.
Repro:
git clone https://github.com/coryvirok/svelte-getsession-order-bug.git
cd svelte-getsession-order-bug && npm i
npm run dev
src/routes/index.js
src/routes/foo.js
You will see the following print out in your server-side console logs:
for GET /
handle() - 1st
getSession() - 3rd
GET / - 2nd
handle() - 4th
for GET /foo
handle() - 1st
GET / - 2nd
handle() - 4th