englercj / resource-loader

A middleware-style generic resource loader built with web games in mind.
http://englercj.github.io/resource-loader/
MIT License
424 stars 77 forks source link

Reload failed resources #147

Closed SlausB closed 4 years ago

SlausB commented 4 years ago

Hello. For some of 100+ files net::ERR_CONNECTION_RESET 200 OK error happens sometimes (every time for different files and in 1 in 20 times game even loads successfully). I failed to google what that error even means. Errors I dealt with previously was 404 (Not Found) which was caused both by absent network or absent files, so I was just reloading the whole page hoping for network connection to recover.

Anyway, error is an error, so failed files need to be recovered somehow, but I don't know how to catch what files failed to load?

PIXI.loader.onError.add( w => console.log( w ) ) Prints: Error: Failed to load element using: IMG

Is there a way to know which file failed to load? How can I add failed file back to the loading bundle continuing the ongoing loading process? If sub-resource failed to load (for example, .png file of .json spritesheet) should I re-queue that sub-resource or it's parent? 

Thanks in advance. 

englercj commented 4 years ago

http://englercj.github.io/resource-loader/classes/loader.html#onerrorsignal

OnError is called with the error, the loader, and the resource that failed.