From cd0dff5c0056a06c7c02a1975554a827db754301 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 2 Jun 2015 00:06:46 +0100 Subject: [PATCH] resourceloader: Use mw.log instead of 'throw' for scripts with syntax errors For scripts loaded from load.php using mw.loader.implement(), an exception is handled fine and results in the module state progressing from 'loading' to 'errror'. However, for wikis modules loaded with only=scripts from the HTML directly, there is no wrapper. As such, the state() call appended to the script is never reached and the module indefinitely stays "loading". VisualEditor (and others) already explicitly ignore the error state of the wiki modules (with inline mw.loader.using and casting the Promise to resolved). However in this case the Promise never completed to neither success nor failure. As such, this was causing users with syntax errors in their user script to encounter a stuck VisualEditor loading bar that never goes beyond 70%. Change-Id: I091a020bdd3392b965e0e25d03b216037fadc48f --- includes/resourceloader/ResourceLoaderModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 57634ab3fc..958990cc7f 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -640,7 +640,7 @@ abstract class ResourceLoaderModule { } catch ( Exception $e ) { // We'll save this to cache to avoid having to validate broken JS over and over... $err = $e->getMessage(); - $result = "throw new Error(" . Xml::encodeJsVar( "JavaScript parse error: $err" ) . ");"; + $result = "mw.log.error(" . Xml::encodeJsVar( "JavaScript parse error: $err" ) . ");"; } $cache->set( $key, $result ); -- 2.20.1