Skip to content

Proactively handle version updates #3666

@Rich-Harris

Description

@Rich-Harris

Describe the problem

As of #3412, SvelteKit is able to recover from navigations that are broken as a result of an updated version, which is important piece of #87.

It's not perfect though — navigations will 'succeed' if the module for the new page is already cached (either in the module cache already, or cached by a service worker) and any relevant endpoints haven't changed in an incompatible way, but the content could well be stale.

Describe the proposed solution

It would arguably be better if we could do one of two things:

  1. Disable the client-side router as soon as a new version is detected
  2. Load a new route manifest in the background so that we can continue using client-side routing

I don't know whether we'd want to always do 1 or 2, or offer developers a means of selecting between them.

If navigation occurred after a new version was deployed but before it was detected, then we'd still use the current behaviour (checking for an update when an error occurs), but if 2 was enabled then we'd presumably attempt to do a client-side navigation with the updated manifest, rather than immediately falling back to a full page navigation.

Updating the manifest behind the scenes adds some complexity. Changes to appDir or src/app.html would necessitate a full page reload (other config changes would be reflected in hashes, so would be accounted for), so we'd need to a) treat a 404 on ${appDir}/version.json as fatal, and b) include a hash of the template in version.json alongside the version string and a pointer to the manifest.

Similarly, new versions of SvelteKit could make it impossible to update gracefully, so if app version B was built with a different Kit version than app version A, we should force a reload. In fact, it's probably a good idea to have a sort of killswitch mechanism for forcing the reload behaviour when you deploy a new version.

Since 2 sounds exhausting, we might want to only do 1 (but perhaps leave open the possibility for 2 in future).

Alternatives considered

We don't need to do this, it's arguably more of a nice-to-have than anything. The current behaviour captures the most common cases, I think.

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changefeature / enhancementNew feature or requestp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions