Fix stale disc file ID in localStorage causing 404 on ROM play after rescan#3374
Merged
Conversation
When a ROM is rescanned and its file IDs change, disc IDs stored in
localStorage become stale. This caused file_ids query params with invalid
IDs to be sent to /api/roms/{id}/content/{name}, resulting in 404 errors.
Validate the stored disc ID against the actual ROM files before use. If
stale, clear localStorage and fall back to the first available file.
Agent-Logs-Url: https://github.com/rommapp/romm/sessions/3579d577-13ff-4288-9a9c-909b6f891c9e
Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix file_id returning as rom_id on API call
Fix stale disc file ID in localStorage causing 404 on ROM play after rescan
May 14, 2026
gantoine
approved these changes
May 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Validates persisted disc selections in localStorage against the ROM's current file list before use, preventing 404 errors when stale IDs remain after a rescan recreates RomFile records.
Changes:
- Validate stored disc ID in EmulatorJS
Base.vueand clear it from localStorage if no longer valid. - Apply the same validation and cleanup in
console/views/Play.vuebefore constructingEJS_gameUrl.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| frontend/src/views/Player/EmulatorJS/Base.vue | Falls back to first file and removes stale localStorage key when stored disc ID is not in rom.files. |
| frontend/src/console/views/Play.vue | Computes a validDiscId and clears playerStorage.disc when the stored ID is stale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
After rescanning ROMs (e.g. when changing the library path),
RomFilerecords are recreated with new IDs. The previously persisted disc selection inlocalStorage(player:{romId}:disc) becomes stale, causing the player to pass an invalid?file_ids=to/api/roms/{id}/content/{name}— resulting in a 404.Changes
views/Player/EmulatorJS/Base.vue— Validate the stored disc ID against the ROM's actual file list before using it. If stale, remove the key fromlocalStorageand fall back to the first available file.console/views/Play.vue— Same validation before constructingEJS_gameUrl. ClearsplayerStorage.discif the stored ID no longer maps to a real file.