diff --git a/src/commands/gateway-install-token.test.ts b/src/commands/gateway-install-token.test.ts index 6df9d3afa36..bd544e57069 100644 --- a/src/commands/gateway-install-token.test.ts +++ b/src/commands/gateway-install-token.test.ts @@ -199,7 +199,10 @@ describe("resolveGatewayInstallToken", () => { }, }, }), - expect.objectContaining({ baseSnapshot: expect.any(Object) }), + expect.objectContaining({ + baseSnapshot: expect.any(Object), + skipRuntimeSnapshotRefresh: true, + }), ); }); diff --git a/src/commands/gateway-install-token.ts b/src/commands/gateway-install-token.ts index 3304963eb90..56fa0acbcf7 100644 --- a/src/commands/gateway-install-token.ts +++ b/src/commands/gateway-install-token.ts @@ -80,6 +80,7 @@ async function maybePersistAutoGeneratedGatewayInstallToken(params: { baseSnapshot: snapshot, ...prepared.writeOptions, ...params.configWriteOptions, + skipRuntimeSnapshotRefresh: true, }, ); return params.token; diff --git a/src/config/io.ts b/src/config/io.ts index 789009ddeae..ad2bab19a2a 100644 --- a/src/config/io.ts +++ b/src/config/io.ts @@ -79,6 +79,7 @@ import { registerRuntimeConfigWriteListener, resetConfigRuntimeState as resetConfigRuntimeStateState, setRuntimeConfigSnapshot as setRuntimeConfigSnapshotState, + getRuntimeConfigSnapshotRefreshHandler as getRuntimeConfigSnapshotRefreshHandlerState, setRuntimeConfigSnapshotRefreshHandler as setRuntimeConfigSnapshotRefreshHandlerState, type RuntimeConfigWriteNotification, } from "./runtime-snapshot.js"; @@ -154,6 +155,11 @@ export type ConfigWriteOptions = { * Avoids rereading the full config just to prepare an immediate write. */ baseSnapshot?: ConfigFileSnapshot; + /** + * Internal one-shot CLI fast path. When no runtime snapshot is active, skip + * the post-write runtime snapshot refresh/reload tail entirely. + */ + skipRuntimeSnapshotRefresh?: boolean; }; export type ReadConfigFileSnapshotForWriteResult = { @@ -1799,7 +1805,15 @@ export async function writeConfigFile( envSnapshotForRestore: options.envSnapshotForRestore, }), unsetPaths: options.unsetPaths, + skipRuntimeSnapshotRefresh: options.skipRuntimeSnapshotRefresh, }); + if ( + options.skipRuntimeSnapshotRefresh && + !hadRuntimeSnapshot && + !getRuntimeConfigSnapshotRefreshHandlerState() + ) { + return; + } const notifyCommittedWrite = () => { const currentRuntimeConfig = getRuntimeConfigSnapshotState(); if (!currentRuntimeConfig) {