@@ -60,6 +60,10 @@ export class ForkPool {
6060 }
6161
6262 async getFork ( context : NuxtDevContext , onMessage ?: ( message : NuxtDevIPCMessage ) => void ) : Promise < ( ) => Promise < void > > {
63+ // Once the app is served by a fork, file changes are no longer visible to
64+ // this process, so a restart is the only signal left that more may follow.
65+ this . warming = true
66+
6367 // Try to get a ready fork from the pool
6468 const readyFork = this . pool . find ( f => f . state === 'ready' )
6569
@@ -70,10 +74,7 @@ export class ForkPool {
7074 }
7175 await this . sendContext ( readyFork . process , context )
7276
73- // Start warming a replacement fork
74- if ( this . warming ) {
75- this . warmFork ( )
76- }
77+ this . warmFork ( )
7778
7879 return ( ) => this . killFork ( readyFork )
7980 }
@@ -88,10 +89,7 @@ export class ForkPool {
8889 }
8990 await this . sendContext ( warmingFork . process , context )
9091
91- // Start warming a replacement fork
92- if ( this . warming ) {
93- this . warmFork ( )
94- }
92+ this . warmFork ( )
9593
9694 return ( ) => this . killFork ( warmingFork )
9795 }
@@ -107,6 +105,8 @@ export class ForkPool {
107105 }
108106 await this . sendContext ( coldFork . process , context )
109107
108+ this . warmFork ( )
109+
110110 return ( ) => this . killFork ( coldFork )
111111 }
112112
@@ -120,6 +120,11 @@ export class ForkPool {
120120 }
121121
122122 private warmFork ( ) : void {
123+ const idle = this . pool . filter ( f => f . state === 'warming' || f . state === 'ready' ) . length
124+ if ( idle >= this . poolSize ) {
125+ return
126+ }
127+
123128 const fork = this . createFork ( )
124129 fork . ready . then ( ( ) => {
125130 if ( fork . state === 'warming' ) {
0 commit comments