Invalidate EmulatorJS ROM cache when a ROM filename changes#3476
Merged
Conversation
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
gantoine
approved these changes
Jun 3, 2026
gantoine
marked this pull request as ready for review
June 3, 2026 19:33
Contributor
There was a problem hiding this comment.
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_nameper ROM inlocalStorageand delete theEmulatorJS-romsIndexedDB 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-romsIndexedDB) persisted across filename changes.Targeted fix
invalidateEmulatorJSRomCacheIfRenamed(rom)infrontend/src/views/Player/EmulatorJS/utils.ts.fs_nameper ROM (player:{rom.id}:fs_name) and deletesEmulatorJS-romsif the filename changed.Integration points
frontend/src/views/Player/EmulatorJS/Player.vuefrontend/src/console/views/Play.vue