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

Data Updates for /post/[slug], But Not For /post #11745

Closed
manunamz opened this issue Jan 27, 2024 · 7 comments
Closed

Data Updates for /post/[slug], But Not For /post #11745

manunamz opened this issue Jan 27, 2024 · 7 comments

Comments

@manunamz
Copy link

manunamz commented Jan 27, 2024

Describe the bug

If you use the same server load function for a root route and a slug route, the root route loses the ability to navigate to slug routes once navigated to.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-wbh3iw?file=src%2Froutes%2Fpost%2F%5B%5Bslug%5D%5D%2F%2Bpage.server.js

If you click on "first post" and then "posts" in the header, it works fine.
If you click "posts" then "first post", you'll see how the content does not update when you click on "first post" this time.
The other routes work as expected.


It is noteworthy that the file structure in the example is:

/src
  /lib
    /routes
      /post
        /[[slug]]
          +page.server.js
          +page.svelte

But this bug persists for different variations that lead to the same routing structure. For example:

/src
  /lib
    /routes
      /post
        +layout.server.js
        +layout.svelte
        +page.svelte
        /[slug]
          +page.svelte

Etc.

Logs

There is no output to either the logs in the terminal on http://localhost:5173/ or in the browser's console.

System Info

System:
    OS: macOS 14.2
    CPU: (8) arm64 Apple M1
    Memory: 56.66 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.2.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.6.6 - /opt/homebrew/bin/npm
    pnpm: 7.8.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Brave Browser: 119.1.60.118
    Chrome: 120.0.6099.129
    Edge: 120.0.2210.61
    Safari: 17.2
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.1.0
    @sveltejs/kit: ^2.0.0 => 2.0.6
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.0.1
    svelte: ^4.2.7 => 4.2.8
    vite: ^5.0.3 => 5.0.11

Severity

annoyance

Additional Information

Discord Post

@gterras
Copy link

gterras commented Jan 27, 2024

Hi,

Yes invalidation is completely broken in SvelteKit, buckle up :

#11635
#11696
#11663
#11446
#10209
#10123
#10457
#10359

Unfortunately the team will read your issue and pretend it doesn't exist just like the other ones.

Meanwhile, features like generating random images of gooses receive a lot of care and attention.

@eltigerchino
Copy link
Member

Hi,

Yes invalidation is completely broken in SvelteKit, buckle up :

#11635 #11696 #11663 #11446 #10209 #10123 #10457 #10359

Unfortunately the team will read your issue and pretend it doesn't exist just like the other ones.

Meanwhile, features like generating random images of gooses receive a lot of care and attention.

Sorry this flew under the radar. I've just forwarded these issues to the team. Thank you for helping to compile a list of these issues.

Personally, I'll try to have a look at these this week when I can, usually after work and other commitments. Recently, I've been giving myself a bit of a break as I've been feeling burnt out from looking at code at work then looking at more code after work so I haven't been looking at any issues in depth.

@manunamz
Copy link
Author

manunamz commented Jan 27, 2024

Someone suggested on discord some workarounds for this particular error -- for example:

export const load = async ({ params: {slug} }) => {
  const post = posts.find((post) => post.slug === slug);
  return { post: post ?? posts[0] };
};

I tried it and it does seem to work! As the author points out, it "seems like kit just doesn't see the dependency on slug without explicit reference".

I will leave this ticket open though, as the original issue is still true and it seems to be symptomatic of deeper issues. Hopefully some of this will help with debugging.

@manunamz
Copy link
Author

manunamz commented Jan 29, 2024

@gterras , could invalidation also be causing this issue #6315 ?

(Not quite sure where to put this question...So here it goes)

@gterras
Copy link

gterras commented Jan 30, 2024

@gterras , could invalidation also be causing this issue #6315 ?

Not sure what you mean this looks like a purely conceptual issue?

@eltigerchino
Copy link
Member

I'm not able to reproduce this issue by following the instructions. The pages load fine in both orders of navigation. Can you re-confirm if you're still seeing this issue?

@benmccann
Copy link
Member

#11870 just fixed a lot of the issues with invalidation, so can you test to see if you're still having issues with 2.5.1?

@eltigerchino eltigerchino closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants