Skip to content

Commit 3ac9089

Browse files
committed
fix(core): restart daemon on Nx version changes
When the Nx version changes, proactively start a new daemon before shutting down, just like lock file changes. This applies to both client message handling and the periodic check.
1 parent d5f4d0e commit 3ac9089

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/nx/src/daemon/server/server.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,23 @@ async function handleMessage(socket: Socket, data: string) {
223223
reason: outdated,
224224
sockets: openSockets,
225225
});
226+
} else if (outdated === 'NX_VERSION_CHANGED') {
227+
// For version changes, start a new daemon before exiting
228+
serverLogger.log(
229+
'Nx version changed, starting new daemon and shutting down'
230+
);
231+
await respondToClient(
232+
socket,
233+
serializeResult(new Error(outdated), null, null),
234+
null
235+
);
236+
await handleServerProcessTerminationWithRestart({
237+
server,
238+
reason: outdated,
239+
sockets: openSockets,
240+
});
226241
} else {
227-
// For version changes, just exit normally
242+
// For other reasons, just exit normally
228243
await respondWithErrorAndExit(
229244
socket,
230245
`Daemon outdated`,
@@ -695,7 +710,10 @@ export async function startServer(): Promise<Server> {
695710

696711
const outdated = daemonIsOutdated();
697712
if (outdated) {
698-
if (outdated === 'LOCK_FILES_CHANGED') {
713+
if (
714+
outdated === 'LOCK_FILES_CHANGED' ||
715+
outdated === 'NX_VERSION_CHANGED'
716+
) {
699717
handleServerProcessTerminationWithRestart({
700718
server,
701719
reason: outdated,

0 commit comments

Comments
 (0)