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

[fix] avoid infinite loop if no routes found #2614

Conversation

baseballyama
Copy link
Member

@baseballyama baseballyama commented Oct 16, 2021

fix: #2602

Please refer My Comment for details.
I handled only src/routes/index.svelte because if another file is not found, we can notice it on browser.
(We can see a 404 message on browser.)

(Is it correct that always src/routes/index.svelte exists?🤔)
-> According to the comment, may not have src/routes/index.svelte.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Oct 16, 2021

🦋 Changeset detected

Latest commit: bf7a7ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Conduitry
Copy link
Member

This isn't the right solution. The root path might be served by an endpoint, or it might not exist at all (especially if the SvelteKit app is behind something that only sends certain URLs to it), or the user may simply be using a different file extension for their page routes.

@baseballyama baseballyama force-pushed the fix/2602-show-error-if-index-svelte-not-found branch from 032db9a to 044cce1 Compare October 17, 2021 01:45
@baseballyama
Copy link
Member Author

@Conduitry

Thank you for telling point what I'm not aware of.
And I updated code.

The direct cause is an infinity loop here.

while (l--) {
pyramid = `
<svelte:component this={components[${l}]} {...(props_${l} || {})}>
{#if components[${l + 1}]}
${pyramid.replace(/\n/g, '\n\t\t\t\t\t')}
{/if}
</svelte:component>
`
.replace(/^\t\t\t/gm, '')
.trim();
}

So I updated it to prevent infinity loop.

And if none of the route components are present, this infinity loop comes.
But I'm not sure that this is a possible use case for kit users.

So right now I added warn message if there is no route component.

packages/kit/src/cli.js Outdated Show resolved Hide resolved
@baseballyama baseballyama force-pushed the fix/2602-show-error-if-index-svelte-not-found branch from da40196 to 6e38aad Compare October 26, 2021 04:28
@benmccann benmccann changed the title [fix] show error message if index.svelte not found [fix] log warning if no routes found Oct 26, 2021
packages/kit/src/cli.js Outdated Show resolved Hide resolved
@benmccann benmccann changed the title [fix] log warning if no routes found [fix] avoid infinite loop if no routes found Oct 27, 2021
@benmccann benmccann merged commit 52c0f99 into sveltejs:master Oct 27, 2021
@@ -118,7 +118,7 @@ function generate_app(manifest_data) {
...manifest_data.routes.map((route) =>
route.type === 'page' ? route.a.filter(Boolean).length : 0
),
0
1
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a little comment explaining what max_depth of 1 then there are actually 0 routes means? It's not immediately obvious that this is produces an error somewhere else as a consequence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dev server hangs when no routes present
4 participants