---
title: "Recover when a new release replaces the · Agent Wranglers"
url: https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/new-release-reload
updated: 2026-10-20
licence: "All rights reserved"
---

# Recover when a new release replaces the old files

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Permissions, flags and failures](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures)
- 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) sets.
- 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.
- 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.

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
import os

BUILD = os.environ["BUILD_ID"]

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

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers app interface playbook: https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/new-release-reload`.

- Previous: [Say when the network is gone](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/offline-behaviour)
- [Permissions, flags and failures](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures)
