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

If pollInterval detects a new version and I click on a not existent link it redirects sine fine #3957

Closed
frederikhors opened this issue Feb 16, 2022 · 12 comments
Labels
bug Something isn't working

Comments

@frederikhors
Copy link
Contributor

Describe the bug

After #3412 if I have an app with adapter-static with this config:

version: {
  name: Date.now().toString(),
  pollInterval: 5 * 1000,
}

if the polling detects the update and I click on a link for a page which doesn't exists instead of rendering the __error.svelte page it keeps in an infinite redirect.

Reproduction

https://github.com/frederikhors/iss-poll-404

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19044
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (98.0.1108.50)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    @sveltejs/adapter-static: 1.0.0-next.28 => 1.0.0-next.28
    @sveltejs/kit: 1.0.0-next.269 => 1.0.0-next.269
    svelte: 3.46.4 => 3.46.4

Severity

blocking an upgrade

Additional Information

No response

@Rich-Harris Rich-Harris added the bug Something isn't working label Mar 2, 2022
@baseballyama
Copy link
Member

@frederikhors

Could you please publish https://github.com/frederikhors/iss-poll-404 ?
I can not access to this repo.

@frederikhors
Copy link
Contributor Author

The repro is here but I cannot reproduce it right now. I think this has something to do with my project which uses a custom sw.

I'll close for now. Thank you @baseballyama.

@jycouet
Copy link
Contributor

jycouet commented Mar 15, 2022

@frederikhors you might be able to help me?
I have something wrong with pollInterval I think.

This: #3412 seems out of date, no?
How do you reload onError? (MP everywhere ;) )

@frederikhors
Copy link
Contributor Author

pollInterval works for me. What is your problem?

@jycouet
Copy link
Contributor

jycouet commented Mar 15, 2022

1/ I deploy my app v22.
2/ My users are on it... Everything is fine.
3/ I deploy my app v23
=> On an action, my users go to an error page (and I can see: "Ressource doesn't exist")

Reading right and left, I found: #3412 and think that it's exactly what I want: onError => reload so that version updates are transparent for my users.
Unfortunately, this kit.browser.router.onError doesn't exist (probably outdated?).

Now, I found out this kit.version.pollInterval. And I guess that it's working, but how to tell my next navigation "please take the new app"? (I'm not on a web worker today, but saw that in web worker it's tracked (not done) there: #3667)

@frederikhors
Copy link
Contributor Author

I'm using pollInterval from here. I'm reloading manually if pollInterval detects new version. For error pages Kit actually in my case fallback to traditional navigation if page doesn't exists and my service worker download automagically the new website version.

@jycouet
Copy link
Contributor

jycouet commented Mar 15, 2022

I'm reloading manually if pollInterval detects new version

How? 😇

my service worker download automagically the new website version.

How? 😇

Do you have a sample code? 🙏

@frederikhors
Copy link
Contributor Author

import { updated } from '$app/stores';

updated.subscribe(async (value) => {
  if (value) {
    if (sw) {
      // handle sw update
    } else {
      window.location.reload();
    }
  }
});

@jycouet
Copy link
Contributor

jycouet commented Mar 15, 2022

Isn't it too "hard" for your users a reload directly?
What if he was typing something?

How do you test the behavior?
because in dev, value never goes to true
same in preview, value never goes to true

Thx for your help :)

@frederikhors
Copy link
Contributor Author

frederikhors commented Mar 15, 2022

Isn't it too "hard" for your users a reload directly?

Nope for this app.

What if he was typing something?

I save the information in the localstorage in almost all dirty forms (when there is worthy information) as does Github.

How do you test the behavior?

I don't. 😄

@jycouet
Copy link
Contributor

jycouet commented Mar 15, 2022

Thx, I'll do the same 😅

@MAYANK-M31
Copy link

import { updated } from '$app/stores';

updated.subscribe(async (value) => {
  if (value) {
    if (sw) {
      // handle sw update
    } else {
      window.location.reload();
    }
  }
});

How to test this in Development Mode ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants