Page MenuHomePhabricator

ResourceLoader: Handle bad file paths more elegantly
Closed, DeclinedPublic

Description

Author: mdale

Description:
When you pass in a non-valid file path to the ResourceLoaderFileModule, The resource loader should send an error to the client in the payload or check these paths at the point in which the path is registered and throw an exception at page render time.

The result of such missing files or error output should not be cached ( even if debug is off )


Version: unspecified
Severity: enhancement

Details

Reference
bz25572

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:22 PM
bzimport set Reference to bz25572.
bzimport added a subscriber: Unknown Object (MLST).

And lets not solve this by adding 1 stat call per file... :)

(In reply to comment #1)

And lets not solve this by adding 1 stat call per file... :)

Did you know PHP (supposedly) has a stat cache causing it to not stat the same file twice during one request?

Then by all means, lets solve this by adding 1 stat call (file_exists) per file :)

mdale wrote:

Right but you probably don't want to stat all resources in every request. Just run the stat call once responding to a resource loader request for the requested resources ( ie right before you read the file, where it will subsequently run stat anyway )

You should add some basic way to have resource loader response to pass down errors or exceptions to javascript. ( ie when outputting a script response and you have an error or exception you should represent that. I previously wrapped errors and used a console.log call, rather than the php html errors that break the javascript processing )

This way if one file is missing the error hits the console but the rest of the javascript does not break.

Furthermore you should treat "error" responses as if "debug" was on. So that the response is not cached.

*bump*

Should this be fixed before the release of 1.17.0 / Completion of ResourceLoader 1.0 ?

(In reply to comment #5)

*bump*

Should this be fixed before the release of 1.17.0 / Completion of
ResourceLoader 1.0 ?

Meh, it's a nice-to-have IMO.

A regular non-load.php request no longer cascades into module contents as far as I know. I don't think it ever did, but perhaps it did (based on reading this bug).

Either way, it doesn't now. When a module contains references to inexistent files, it s gracefully detected by the startup module (so the other modules load file), a message is logged to the resourceloader log (server-side) and an exception is logged in a js comment atop the startup module request.