-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fixes SPA mode error handling #4049
Conversation
🦋 Changeset detectedLatest commit: eb414d5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Thanks — can we add a test for this? Not sure how to reproduce the original bug |
@Rich-Harris I'm not sure how to test it, I think it would be really flaky. I think the racing occurs with ticks, and |
Also, we are awaiting for hydrate already, so it's not precedent to wait(but I understand that the hydrate function executes faster because it doesn't really have to do network calls), and if (hydrate) await renderer.start(hydrate);
if (router) {
if (spa) {router.goto(location.href, { replaceState: true }, []).then(()=>{router.initialized = true;});}
router.init_listeners();
if (!spa) {router.initialized = true;}
} and remove and the last option is to use another parameter for So the second solution looks alright. |
Actually the second solution could be simplified to this: if (hydrate) await renderer.start(hydrate);
if (router) {
router.init_listeners();
if (spa) await router.goto(location.href, { replaceState: true }, []);
router.initialized = true;
} |
I just can't reproduce this at all. As far as I can tell, the relevant question is whether the initial So I don't understand how it's possible for |
@Rich-Harris I fully understand that it would be irresponsible to merge it without all the details, so here is a repro
run To be honest, when I tried to recreate issue in new repro, I really couldn't easily do it, and as far as I can see |
So it seems to happen post-initialization on kit/packages/kit/src/runtime/client/renderer.js Lines 171 to 179 in 266a460
|
Ah, interesting. That suggests this is the wrong fix — it only appears to fix the issue because the session update happens during the initial hydration. Not sure what the correct fix looks like |
@Rich-Harris @mrkishi closing this PR, will try to come up with something more in-depth and send PR. |
One possible solution is that we just add another parameter to |
Related to #3969
Needed await.