MCPcopy
hub / github.com/claude-code-best/claude-code / startDeferredPrefetches

Function startDeferredPrefetches

src/main.tsx:535–580  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

533 * Call this after the REPL has been rendered.
534 */
535export function startDeferredPrefetches(): void {
536 // This function runs after first render, so it doesn't block the initial paint.
537 // However, the spawned processes and async work still contend for CPU and event
538 // loop time, which skews startup benchmarks (CPU profiles, time-to-first-render
539 // measurements). Skip all of it when we're only measuring startup performance.
540 if (
541 isEnvTruthy(process.env.CLAUDE_CODE_EXIT_AFTER_FIRST_RENDER) ||
542 // --bare: skip ALL prefetches. These are cache-warms for the REPL's
543 // first-turn responsiveness (initUser, getUserContext, tips, countFiles,
544 // modelCapabilities, change detectors). Scripted -p calls don't have a
545 // "user is typing" window to hide this work in — it's pure overhead on
546 // the critical path.
547 isBareMode()
548 ) {
549 return;
550 }
551
552 // Process-spawning prefetches (consumed at first API call, user is still typing)
553 void initUser();
554 void getUserContext();
555 prefetchSystemContextIfSafe();
556 void getRelevantTips();
557 if (isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) && !isEnvTruthy(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)) {
558 void prefetchAwsCredentialsAndBedRockInfoIfSafe();
559 }
560 if (isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) && !isEnvTruthy(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)) {
561 void prefetchGcpCredentialsIfSafe();
562 }
563 void countFilesRoundedRg(getCwd(), AbortSignal.timeout(3000), []);
564
565 // Analytics and feature flag initialization
566 void initializeAnalyticsGates();
567
568 void refreshModelCapabilities();
569
570 // File change detectors deferred from init() to unblock first render
571 void settingsChangeDetector.initialize();
572 if (!isBareMode()) {
573 void skillChangeDetector.initialize();
574 }
575
576 // Event loop stall detector — logs when the main thread is blocked >500ms
577 if (process.env.USER_TYPE === 'ant') {
578 void import('./utils/eventLoopStallDetector.js').then(m => m.startEventLoopStallDetector());
579 }
580}
581
582function loadSettingsFromFlag(settingsFile: string): void {
583 try {

Callers 2

renderAndRunFunction · 0.85
runFunction · 0.85

Calls 11

isBareModeFunction · 0.85
initUserFunction · 0.85
getRelevantTipsFunction · 0.85
getCwdFunction · 0.85
initializeAnalyticsGatesFunction · 0.85
refreshModelCapabilitiesFunction · 0.85
initializeMethod · 0.65
isEnvTruthyFunction · 0.50

Tested by

no test coverage detected