kit icon indicating copy to clipboard operation
kit copied to clipboard

+page.server.ts and +layout.server.ts causing infinite reloads

Open kr-keshav-kk opened this issue 1 year ago • 3 comments

Describe the bug

When i hit myApp/testing it works fine, but on hitting myApp/main/buy it starts to reload again and again in an infinte loop. This is happening only on server, but if i run the build file on my system using npm run preview it works fine. I am using load function inside it. But for testing purpose i am not calling any api inside the load function.

I have folder structure similar to:

-routes folder

--main folder ---buy folder ---- +page.server.ts ---- +page.svelte

--testing folder --- +page.server.ts --- +page.svelte

As a matter of fact if i use +layout.server.ts anywhere in my current route it just causes infine reload of my webpage(on server).

Reproduction

https://github.com/sveltejs/kit/assets/138488364/3203fc7e-1e35-434f-9be7-9bbfe5b8b61a

Logs

No response

System Info

My local:
"vite": "^4.5.2",
"svelte": "^4.2.0",
node: v18.16.1

Server: ubuntu

Severity

blocking an upgrade

Additional Information

Any idea is appreciated as i am open to do hit and trial for any workaround

kr-keshav-kk avatar Feb 10 '24 22:02 kr-keshav-kk

Please provide a minimal reproduction in the form of a code repository.

eltigerchino avatar Feb 11 '24 08:02 eltigerchino

I have a similar issue - but not an infinite reload.

Occasonally in dev mode, the server stops responding on a route which has both layout+page.server. The hooks.server.ts aren't called for this route. Other routes work fine and hooks are called.

If I start and stop the server, it's still broken. I'm doing a build to clean up everything at the moment.

If I delete the page.server everything works.

I can also make this happen by editting the svelte.config (no change but just a say adding new line to force recompilation).

I haven't managed to recreate in a new repo - I've got Prisma (calls in both page and layout), Luxia and I do a fetch in the layout. So quite a bit doing on (could be some form of race condition between page+layout.

chrisflatley avatar Feb 14 '24 08:02 chrisflatley

Please provide a minimal reproduction in the form of a code repository.

i will try to give you. Problem is that its the entire project that is behaving in that way. It is difficult to isolate the problem creating code.

But one thing to note is that as soon as load function is added in +page.server.ts things start to break.

kr-keshav-kk avatar Feb 18 '24 12:02 kr-keshav-kk