File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -157,20 +157,30 @@ JsonpMainTemplatePlugin.prototype.apply = function(mainTemplate) {
157157 return callback ( new Error ( "No browser support" ) ) ;
158158 try {
159159 var request = new XMLHttpRequest ( ) ;
160- request . open ( "GET" , $require$ . p + $hotMainFilename$ , true ) ;
160+ var requestPath = $require$ . p + $hotMainFilename$ ;
161+ request . open ( "GET" , requestPath , true ) ;
162+ request . timeout = 10000 ;
161163 request . send ( null ) ;
162164 } catch ( err ) {
163165 return callback ( err ) ;
164166 }
165167 request . onreadystatechange = function ( ) {
166168 if ( request . readyState !== 4 ) return ;
167- if ( request . status !== 200 && request . status !== 304 ) {
169+ if ( request . status === 0 ) {
170+ // timeout
171+ callback ( new Error ( "Manifest request to " + requestPath + " timed out." ) ) ;
172+ } else if ( request . status === 404 ) {
173+ // no update available
168174 callback ( ) ;
175+ } else if ( request . status !== 200 && request . status !== 304 ) {
176+ // other failure
177+ callback ( new Error ( "Manifest request to " + requestPath + " failed." ) ) ;
169178 } else {
179+ // success
170180 try {
171181 var update = JSON . parse ( request . responseText ) ;
172182 } catch ( e ) {
173- callback ( ) ;
183+ callback ( e ) ;
174184 return ;
175185 }
176186 callback ( null , update ) ;
You can’t perform that action at this time.
0 commit comments