---
title: "Recover when a new release replaces the · Agent Wranglers"
url: https://agentwranglers.se/playbook/app-ui/resilience/new-release-reload
id: APP-53
level: Recommended
updated: 2026-10-22
build: a2a6bdfed830
tokens: 824
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Recover when a new release replaces the old files

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Resilience](https://agentwranglers.se/playbook/app-ui/resilience.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: APP-53
- Level: Recommended
- Chapter: [Resilience](https://agentwranglers.se/playbook/app-ui/resilience.md)
- Rule: When a tab still runs the old release and a code chunk fails to load after a deploy, reload once to get the new release. Keep older files online as [keep the previous build's assets](https://agentwranglers.se/playbook/website/site-architecture/keep-the-previous-build-s-assets.md) sets.
- Check: Deploy a release to staging, then click an in-app link in a tab opened before the deploy. The next screen loads, and the tab reloads at most once.
- How: A tab opened before a deploy asks for chunk files that the new release may have removed. Catch failed dynamic imports, such as Vite's `vite:preloadError` event or webpack's `ChunkLoadError`, save any draft, and reload once. Store the reload time in `sessionStorage`, and skip a second reload within a minute, so a broken release can't loop. Also check the build version from a small endpoint and offer a reload when it changes.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### TypeScript example

```ts
const RELOAD_FLAG = 'reloaded-for-release';

const RELOAD_GUARD_MS = 60_000;

addEventListener('vite:preloadError', event => {
  const lastReload = Number(sessionStorage.getItem(RELOAD_FLAG) ?? 0);
  if (Date.now() - lastReload < RELOAD_GUARD_MS) return;
  event.preventDefault();
  sessionStorage.setItem(RELOAD_FLAG, String(Date.now()));
  saveDrafts();
  location.reload();
});
```

### Python example

```python
import os

BUILD = os.environ["BUILD_ID"]

@app.get("/api/version")
def version():
    return {"build": BUILD}, 200, {"Cache-Control": "no-store"}
```

## Sources

- [Vite guide on load error handling](https://vite.dev/guide/build#load-error-handling)

## Related rules

- WEB-23 [Keep the previous build's assets](https://agentwranglers.se/playbook/website/site-architecture/keep-the-previous-build-s-assets.md) in Website
- WEB-267 [Ship new service workers without trapping old ones](https://agentwranglers.se/playbook/website/offline-and-installed-apps/service-worker-updates.md) in Website

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/app-ui/resilience/new-release-reload">Agent Wranglers web app interface playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Say when the network is gone](https://agentwranglers.se/playbook/app-ui/resilience/offline-behaviour.md)
- Next: [Read feature flags before the first paint](https://agentwranglers.se/playbook/app-ui/resilience/feature-flags-in-ui.md)
- [Resilience](https://agentwranglers.se/playbook/app-ui/resilience.md)
