@@ -21,7 +21,7 @@ import Path from 'path';
2121
2222import { REPO_ROOT } from '@kbn/dev-utils' ;
2323import * as Rx from 'rxjs' ;
24- import { mapTo , filter , take } from 'rxjs/operators' ;
24+ import { mapTo , filter , take , tap , distinctUntilChanged , switchMap } from 'rxjs/operators' ;
2525
2626import { CliArgs } from '../../core/server/config' ;
2727import { LegacyConfig } from '../../core/server/legacy' ;
@@ -142,6 +142,15 @@ export class CliDevMode {
142142 ]
143143 : [ ] ) ,
144144 ] ,
145+ mapLogLine : ( line ) => {
146+ if ( ! this . basePathProxy ) {
147+ return line ;
148+ }
149+
150+ return line
151+ . split ( `${ this . basePathProxy . host } :${ this . basePathProxy . targetPort } ` )
152+ . join ( `${ this . basePathProxy . host } :${ this . basePathProxy . port } ` ) ;
153+ } ,
145154 } ) ;
146155
147156 this . optimizer = new Optimizer ( {
@@ -168,10 +177,41 @@ export class CliDevMode {
168177 this . subscription = new Rx . Subscription ( ) ;
169178
170179 if ( basePathProxy ) {
171- const delay$ = firstAllTrue ( this . devServer . isReady$ ( ) , this . optimizer . isReady$ ( ) ) ;
180+ const serverReady$ = new Rx . BehaviorSubject ( false ) ;
181+ const optimizerReady$ = new Rx . BehaviorSubject ( false ) ;
182+ const userWaiting$ = new Rx . BehaviorSubject ( false ) ;
183+
184+ this . subscription . add (
185+ Rx . merge (
186+ this . devServer . isReady$ ( ) . pipe ( tap ( serverReady$ ) ) ,
187+ this . optimizer . isReady$ ( ) . pipe ( tap ( optimizerReady$ ) ) ,
188+ userWaiting$ . pipe (
189+ distinctUntilChanged ( ) ,
190+ switchMap ( ( waiting ) =>
191+ ! waiting
192+ ? Rx . EMPTY
193+ : Rx . timer ( 1000 ) . pipe (
194+ tap ( ( ) => {
195+ this . log . warn (
196+ 'please hold' ,
197+ ! optimizerReady$ . getValue ( )
198+ ? 'optimizer is still bundling so requests have been paused'
199+ : 'server is not ready so requests have been paused'
200+ ) ;
201+ } )
202+ )
203+ )
204+ )
205+ ) . subscribe ( this . observer ( 'readiness checks' ) )
206+ ) ;
172207
173208 basePathProxy . start ( {
174- delayUntil : ( ) => delay$ ,
209+ delayUntil : ( ) => {
210+ userWaiting$ . next ( true ) ;
211+ return firstAllTrue ( serverReady$ , optimizerReady$ ) . pipe (
212+ tap ( ( ) => userWaiting$ . next ( false ) )
213+ ) ;
214+ } ,
175215 shouldRedirectFromOldBasePath,
176216 } ) ;
177217
0 commit comments