@@ -5,6 +5,7 @@ import path from "node:path";
55import { withSuppressedNotes } from "../../../packages/terminal-core/src/note.js" ;
66import { readConfigFileSnapshot , setRuntimeConfigSnapshot } from "../../config/config.js" ;
77import { createInvalidConfigError } from "../../config/io.invalid-config.js" ;
8+ import type { ConfigSnapshotReadMeasure } from "../../config/io.js" ;
89import {
910 resolveIsNixMode ,
1011 resolveLegacyStateDirs ,
@@ -189,16 +190,22 @@ function isGatewayStartupCommand(commandPath: string[]): boolean {
189190 ) ;
190191}
191192
192- async function getConfigSnapshot ( options ?: { observe : false ; skipPluginValidation ?: true } ) {
193+ async function getConfigSnapshot (
194+ options ?: { observe : false ; skipPluginValidation ?: true } ,
195+ measure ?: ConfigSnapshotReadMeasure ,
196+ ) {
193197 if ( options ?. observe === false ) {
194- return readConfigFileSnapshot ( options ) ;
198+ return readConfigFileSnapshot ( {
199+ ...options ,
200+ ...( measure ? { measure } : { } ) ,
201+ } ) ;
195202 }
196203 // Tests often mutate config fixtures; caching can make those flaky.
197204 if ( process . env . VITEST === "true" ) {
198- return readConfigFileSnapshot ( ) ;
205+ return readConfigFileSnapshot ( measure ? { measure } : undefined ) ;
199206 }
200207 if ( ! configSnapshotPromise ) {
201- const pendingSnapshot = readConfigFileSnapshot ( ) ;
208+ const pendingSnapshot = readConfigFileSnapshot ( measure ? { measure } : undefined ) ;
202209 configSnapshotPromise = pendingSnapshot ;
203210 pendingSnapshot . catch ( ( ) => {
204211 if ( configSnapshotPromise === pendingSnapshot ) {
@@ -216,6 +223,7 @@ export async function ensureConfigReady(
216223 suppressDoctorStdout ?: boolean ;
217224 allowInvalid ?: boolean ;
218225 beforeStateMigrations ?: ( snapshot ?: ConfigFileSnapshot ) => Promise < boolean > ;
226+ measure ?: ConfigSnapshotReadMeasure ;
219227 skipPristineCoreStateMigrations ?: boolean ;
220228 skipPristineStartupStateMigrations ?: boolean ;
221229 } ,
@@ -234,6 +242,7 @@ export async function ensureConfigReady(
234242 migrateState : true ,
235243 migrateLegacyConfig : false ,
236244 invalidConfigNote : false ,
245+ ...( params . measure ? { measure : params . measure } : { } ) ,
237246 ...( commandName === "status" ? { observe : false } : { } ) ,
238247 ...( shouldRequireStartupMigrationCheckpoint ( commandPath )
239248 ? { requireStartupMigrationCheckpoint : true }
@@ -276,7 +285,8 @@ export async function ensureConfigReady(
276285 : commandName === "status" || ( commandName === "gateway" && subcommandName === "call" )
277286 ? ( { observe : false } as const )
278287 : undefined ;
279- let snapshot = preflightSnapshot ?? ( await getConfigSnapshot ( configSnapshotOptions ) ) ;
288+ let snapshot =
289+ preflightSnapshot ?? ( await getConfigSnapshot ( configSnapshotOptions , params . measure ) ) ;
280290 if (
281291 ! preflightSnapshot &&
282292 ! didRunDoctorConfigFlow &&
@@ -392,6 +402,7 @@ export async function ensureConfigReady(
392402 migrateState : false ,
393403 migrateLegacyConfig : false ,
394404 invalidConfigNote : false ,
405+ ...( params . measure ? { measure : params . measure } : { } ) ,
395406 ...configSnapshotOptions ,
396407 } )
397408 ) . snapshot ;
0 commit comments