-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
Unsafe store behaviour of utility components in SvelteKit #522
Comments
@niktek Tagging you to help review this. FYI, I was aiming to bring the Drawer in line with Dialog/Toast stores soon, so we need to review the repercussions of this. |
After reviewing with the team we're going to take the stance that this is important, but not something we can solve easily on our side. If SvelteKit comes out with a hard stance on this or recommend fix or work around then we'll follow suit. For now I'm going to close this, but I recommend you Buni, or anyone that comes cross this to help keep an eye on progress on this issue. Thanks for bringing this to our attention! |
@endigo9740 considering this doesn't look like the svelte team are interested in fixing this issue, would you be interested in me raising a PR using the workaround suggested in this comment: sveltejs/kit#4339 (comment) Also if this was to be added, probably makes more sense to try and get it in pre 1.0 in case there's any breaking changes (although hopefully it should all just be behind the scenes) If the svelte team release an official solution for the problem we can obviously update in the future to reflect that, but in the meantime this would at least mean those warnings can be removed from the docs and make Skeleton just a little bit easier to use for devs? |
@DevOfManyThings I don't think this is a problem Skeleton should aim to solve. We're not Svelte, we're not SvelteKit, we're not going to aim to solve their problems. I'd suggest you try and create a PR to submit TO SvelteKit. But my assumption is they'll get to this, it may just take some time. With SvelteKit v1 out the door I've heard they're turning their attention back to Svelte v4. We should wait and see wha pans out from that. |
@endigo9740 I know you're sick of the store issue as it's not Skeletons fault, but would you be open to a PR which replaces the official svelte stores for this library? The lib is tiny but solves the issue. This change would not cause any changes to existing behaviours/functionality, so it wouldn't be a breaking change and means the SSR warnings could be removed, putting this issue to bed permanently. |
@DevOfManyThings extra dependencies are always going to be the "nuclear" option for us. So this is unlikely. That said @AdrianGonz97 has mentioned he has some ideas for solving this. I'll let him chime in when he can, but his proposal did sound like it may be a breaking change. So this is not something we would rush in. You're welcome to coordinate with him on this though. |
@DevOfManyThings Thanks for the suggestion! I took a look at the implementation of package and I don't think it'd be a great fit for us. Unfortunately, the package relies on Regarding the issue with stores, I'm currently working on an alternative that'll place the responsibility of the store onto the user rather than us handling it for them. I think it should work but it'll be a breaking change and something that would have to be implemented for Skeleton v2. |
@AdrianGonz97 That dependency is just a I do like the sound of that alternative (I imagine if Skeleton wants to go framework independent then that would also be necessary!) The benefit of this approach is it should be non-breaking so could be added in a minor release as a fix until v2 comes around? |
This is now resolved and will be a part of the v2 release coming later today. |
Current Behavior
Currently components like Toast use exported const stores to function. This is completely fine for all uses cases outside of SvelteKit, as any const variable imported from a library will become global/shared state between requests. This could and will cause unintended behaviour when using SvelteKit.
I haven't spent time to properly test what the impact would be in skeleton's case, so I don't know what would break.
Potential solutions were discussed in discord, also the way Drawers are written should mean that they are safe to use, it looks like only Dialog and Toast are affected.
Steps To Reproduce
Import any const store in sveltekit with SSR enabled.
Anything else?
Dicussion about shared state/stores and SvelteKIt
Issue about shared state behaviour
Another related issue
The text was updated successfully, but these errors were encountered: