@@ -718,7 +718,7 @@ class Server {
718
718
this . options . port ,
719
719
this . options . host ,
720
720
( error ) => {
721
- if ( this . options . hot || this . options . liveReload ) {
721
+ if ( Boolean ( this . options . hot ) || this . options . liveReload ) {
722
722
this . createWebSocketServer ( ) ;
723
723
}
724
724
@@ -936,26 +936,28 @@ class Server {
936
936
}
937
937
938
938
serveMagicHtml ( req , res , next ) {
939
- const _path = req . path ;
939
+ this . middleware . waitUntilValid ( ( ) => {
940
+ const _path = req . path ;
940
941
941
- try {
942
- const filename = this . middleware . getFilenameFromUrl ( `${ _path } .js` ) ;
943
- const isFile = this . middleware . context . outputFileSystem
944
- . statSync ( filename )
945
- . isFile ( ) ;
942
+ try {
943
+ const filename = this . middleware . getFilenameFromUrl ( `${ _path } .js` ) ;
944
+ const isFile = this . middleware . context . outputFileSystem
945
+ . statSync ( filename )
946
+ . isFile ( ) ;
946
947
947
- if ( ! isFile ) {
948
- return next ( ) ;
949
- }
948
+ if ( ! isFile ) {
949
+ return next ( ) ;
950
+ }
950
951
951
- // Serve a page that executes the javascript
952
- const queries = req . _parsedUrl . search || '' ;
953
- const responsePage = `<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body><script type="text/javascript" charset="utf-8" src="${ _path } .js${ queries } "></script></body></html>` ;
952
+ // Serve a page that executes the javascript
953
+ const queries = req . _parsedUrl . search || '' ;
954
+ const responsePage = `<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body><script type="text/javascript" charset="utf-8" src="${ _path } .js${ queries } "></script></body></html>` ;
954
955
955
- res . send ( responsePage ) ;
956
- } catch ( error ) {
957
- return next ( ) ;
958
- }
956
+ res . send ( responsePage ) ;
957
+ } catch ( error ) {
958
+ return next ( ) ;
959
+ }
960
+ } ) ;
959
961
}
960
962
961
963
// Send stats to a socket or multiple sockets
0 commit comments