Skip to content

Invalidate EmulatorJS ROM cache when a ROM filename changes#3476

Merged
gantoine merged 2 commits into
masterfrom
copilot/fix-network-error-emulatorjs
Jun 3, 2026
Merged

Invalidate EmulatorJS ROM cache when a ROM filename changes#3476
gantoine merged 2 commits into
masterfrom
copilot/fix-network-error-emulatorjs

Conversation

Copilot AI commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Renaming a ROM from the game edit UI could leave EmulatorJS using stale cached ROM content, causing a runtime “Network Error” on play until users manually cleared browser storage. This change makes cache invalidation automatic when the ROM filename changes.

  • Root cause addressed

    • EmulatorJS ROM cache (EmulatorJS-roms IndexedDB) persisted across filename changes.
    • Player startup reused cached data keyed from prior ROM filename state.
  • Targeted fix

    • Added invalidateEmulatorJSRomCacheIfRenamed(rom) in frontend/src/views/Player/EmulatorJS/utils.ts.
    • The helper stores last-seen fs_name per ROM (player:{rom.id}:fs_name) and deletes EmulatorJS-roms if the filename changed.
  • Integration points

    • Wired into standard EmulatorJS player bootstrap:
      • frontend/src/views/Player/EmulatorJS/Player.vue
    • Wired into console play bootstrap for parity:
      • frontend/src/console/views/Play.vue
export function invalidateEmulatorJSRomCacheIfRenamed(rom: {
  id: number;
  fs_name: string;
}) {
  const key = `player:${rom.id}:fs_name`;
  const previousFsName = localStorage.getItem(key);

  if (previousFsName && previousFsName !== rom.fs_name) {
    window.indexedDB.deleteDatabase("EmulatorJS-roms");
  }

  localStorage.setItem(key, rom.fs_name);
}

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix network error when renaming rom files Invalidate EmulatorJS ROM cache when a ROM filename changes Jun 3, 2026
Copilot AI requested a review from gantoine June 3, 2026 19:08
@gantoine
gantoine marked this pull request as ready for review June 3, 2026 19:33
Copilot AI review requested due to automatic review settings June 3, 2026 19:33
@gantoine
gantoine merged commit fd78c79 into master Jun 3, 2026
10 checks passed
@gantoine
gantoine deleted the copilot/fix-network-error-emulatorjs branch June 3, 2026 19:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents EmulatorJS from using stale cached ROM data after a ROM is renamed, by detecting filename changes and invalidating the EmulatorJS ROM IndexedDB cache during player boot.

Changes:

  • Added a helper to track last-seen fs_name per ROM in localStorage and delete the EmulatorJS-roms IndexedDB when it changes.
  • Wired the helper into the standard EmulatorJS Player bootstrap.
  • Wired the helper into the console “Play” bootstrap for parity.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
frontend/src/views/Player/EmulatorJS/utils.ts Adds the cache invalidation helper based on stored prior fs_name.
frontend/src/views/Player/EmulatorJS/Player.vue Calls the invalidation helper during EmulatorJS global bootstrap.
frontend/src/console/views/Play.vue Calls the invalidation helper during console EmulatorJS bootstrap.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +156 to +158
if (previousFsName && previousFsName !== rom.fs_name) {
window.indexedDB.deleteDatabase("EmulatorJS-roms");
}
Comment on lines +149 to +152
export function invalidateEmulatorJSRomCacheIfRenamed(rom: {
id: number;
fs_name: string;
}) {
getDownloadPath,
} from "@/utils";
import { buildFormInput } from "@/utils/formData";
import { invalidateEmulatorJSRomCacheIfRenamed } from "@/views/Player/EmulatorJS/utils";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Network error (emulatorJS) when rom file renamed

3 participants