Frontmatter
| id | 8498 |
| title | ServiceWorker.preloadAssets crashes on 404s instead of handling errors gracefully |
| state | Closed |
| labels | bugaicore |
| assignees | tobiu |
| createdAt | Jan 10, 2026, 12:45 PM |
| updatedAt | Jan 10, 2026, 12:58 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8498 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 10, 2026, 12:58 PM |
ServiceWorker.preloadAssets crashes on 404s instead of handling errors gracefully
tobiu assigned to @tobiu on Jan 10, 2026, 12:46 PM

tobiu
Jan 10, 2026, 12:58 PM
Input from tobiu:
◆ Refactored
preloadAssetsto gracefully handle fetch errors (e.g., 404s) and provide detailed result metrics.New Behavior:
- No Crash: The method no longer throws/rejects if individual assets fail to load. It catches errors per file.
- Strict Success: The
successflag now indicates strict completion.trueonly if all requested files are available (pre-cached or successfully fetched).falseif any file failed.- Success Ratio: Added a
ratioproperty (0 to 1) indicating the percentage of available assets.- Detailed Reporting: Returns a
failedarray containing the URLs that could not be loaded.Return Object:
{ failed: ['https://example.com/missing.jpg'], ratio: 0.9, // 9/10 successful success: false }This allows developers to decide whether a partial success is acceptable for their use case.
tobiu closed this issue on Jan 10, 2026, 12:58 PM
The
Neo.ServiceWorker.preloadAssetsmethod fails completely if any of the requested URLs return a 404 or network error.Current Behavior: The method uses
cache.addAll(items). If any request in the list fails,cache.addAllrejects the entire promise, adding none of the files to the cache. This results in an unhandled promise rejection or a crash in the calling code.Error:
Goal: Make
preloadAssetsmore robust. It should gracefully handle failures, ideally by:addAllfails (or by design), iterating and adding files individually so that valid files are cached even if one is missing.{success: true, failed: ['url1', 'url2']}) instead of crashing.Proposed Solution: Modify
src/worker/ServiceBase.mjs->preloadAssetsto catch errors during fetch/cache operations and report partial successes or specific failures.