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

Page endpoint without a GET handler causes client-side navigation to hang #4253

Closed
Rich-Harris opened this issue Mar 6, 2022 · 8 comments
Closed
Labels
bug Something isn't working help wanted PRs welcomed. The implementation details are unlikely to cause debate p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.
Milestone

Comments

@Rich-Harris
Copy link
Member

Describe the bug

If a page has an endpoint without a get handler, client-side navigation hands indefinitely

Reproduction

Go to https://stackblitz.com/edit/sveltejs-kit-template-default-v3d3wq?file=src%2Froutes%2Fabout.js&terminal=dev, click the ABOUT link in the nav

Logs

No response

System Info

System:
    OS: macOS 12.0.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 169.98 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.1/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 98.0.4758.109
    Firefox: 97.0.1
    Safari: 15.1
  npmPackages:
    svelte: ^3.43.0 => 3.44.2

Severity

annoyance

Additional Information

No response

@Rich-Harris Rich-Harris added the bug Something isn't working label Mar 6, 2022
@Rich-Harris Rich-Harris added this to the 1.0 milestone Mar 6, 2022
@am283721
Copy link
Contributor

am283721 commented Mar 7, 2022

Interestingly, I see the issue in the repro but I can't seem to reproduce it locally on any browser. It might be worth noting that it fails to build the project without setting prerender to false on the about page (due to having an endpoint with mutative methods).

An error in the stackblitz repro eventually did display (I think triggered by the anchor prefetch):

Screen Shot 2022-03-07 at 10 49 23 AM

The error in start.js is from trying to fetch from __data.json:

if (is_shadow_page) {
  const res = await fetch(
	  `${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json${url.search}`,
	  {
		  headers: {
			  'x-sveltekit-load': /** @type {string} */ (shadow_key)
		  }
	  }
  );
....

@lsl
Copy link

lsl commented Mar 8, 2022

Any chance this is related to this change?

204 is now being used to mean both fallthrough and redirect. Routes are loading shadow pages for less specific routes (e.g a wildcard route when the first route responds with nothing (or in my case, a redirect).

Looks like maybe @aolose has a fix that works for my issue in #4260, it might also fix this issue?

@benmccann benmccann added the p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc. label Mar 17, 2022
@benmccann benmccann added help wanted PRs welcomed. The implementation details are unlikely to cause debate and removed help wanted labels Apr 4, 2022
@WholeStackDev
Copy link

@lsl I confirmed that the issue does not occur when running @sveltejs/kit 1.0.0-next.291 but does occur when running 1.0.0-next.292. The change you mentioned, #4203, did go in on release 292, so that sounds like the culprit. I don't know enough to be able to say why it broke it, but I can at least narrow stuff down!

Here are the repros showing it working on 291 and breaking on 292:

291 = https://stackblitz.com/edit/sveltejs-kit-template-default-yyw5ho
292 = https://stackblitz.com/edit/sveltejs-kit-template-default-dbtggu

@tadmccorkle
Copy link

tadmccorkle commented Apr 12, 2022

Is this still an issue with SvelteKit or just something off with StackBlitz? StackBlitz is the only place I've been able to reproduce the issue. I can still reproduce it there as of SvelteKit 1.0.0-next.311 (https://stackblitz.com/edit/sveltejs-kit-template-default-ng3dc8), although it's a little finicky - sometimes it won't hang if I quickly hit the About link after reboot of the webcontainer or HMR, but it starts to hang a few seconds later.

I've tried to reproduce locally from scratch and by copying my StackBlitz project source files, but it never hangs when navigating to a page endpoint w/o a GET handler.

Also, there seems to be a test that currently passes for this exact case:

cd packages/kit/test/apps/basics/
npx playwright test -g 'Endpoint without GET'

@elliott-with-the-longest-name-on-github
Copy link
Contributor

I concur that this seems to be an issue with StackBlitz -- I tried it on both Chrome and Firefox on Windows and Ubuntu, and couldn't replicate it in any of those, though the issue still persists on next-347 on StackBlitz.

@lunacd
Copy link
Contributor

lunacd commented Jun 30, 2022

Same. Cannot repro locally. Would suggest closing this as a non-SvelteKit issue.

@Rich-Harris
Copy link
Member Author

Locally, about/__data.json is a 204 (what?) response with the following contents:

GET method not allowed

That shouldn't happen. Browsers seem to take it in their stride, but presumably the service worker that handles requests in StackBlitz doesn't like it. Even though it 'works' in browsers, StackBlitz is exposing a legitimate bug, so I think this needs to stay open.

@dummdidumm
Copy link
Member

This was fixed as part of #5778 since __data.json is now always present because it queries not only the page endpoint, but everything leading up to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted PRs welcomed. The implementation details are unlikely to cause debate p1-important SvelteKit cannot be used by a large number of people, basic functionality is missing, etc.
Projects
None yet
Development

No branches or pull requests

9 participants