Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop when accessing prerendered +server.js from matching non-prerendered +server.js #12778

Open
dummdidumm opened this issue Oct 9, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@dummdidumm
Copy link
Member

dummdidumm commented Oct 9, 2024

Describe the bug

Given this structure

[id].json/+server
examples.json/+server

with examples.json being prerendered and [id].json fetching examples.json, the server is fine at dev time but crashes in prod. The manifest seems to not properly resolve the correct route, instead of fetching the prerendered examples.json it recursively calls itself in [id].json. My guess is that the runtime first tries to find a matching "live" route before checking if a prerendered one exists.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-fhjdvp?file=src%2Froutes%2F%2Bpage.server.js

Logs

No response

System Info

SvelteKit 2.6.3

Severity

annoyance

Additional Information

can be worked around by making sure the routes don't match

@dummdidumm dummdidumm added the bug Something isn't working label Oct 9, 2024
@dummdidumm
Copy link
Member Author

A variation of this is when you have a prerendered +server.js next to a non-prerendered +page(.server).js, and the load function wants to access the prerendered result. It doesn't end up in an infinite loop in this case but the bug is the same.

@eltigerchino
Copy link
Member

eltigerchino commented Dec 11, 2024

We currently don't have any check for prerendered routes since they're removed from the manifest. We only have a check for static assets before it tries to respond with a route.

if (is_asset || is_asset_html) {

Do you think we should re-include prerendered routes in the manifest somehow so that we can perform this check?

@dummdidumm
Copy link
Member Author

Can also happen with spread routes as seen in #11927

@dummdidumm
Copy link
Member Author

Probably related: #12739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants