CLI: skip redundant registry probes during sandbox creation#35356
CLI: skip redundant registry probes during sandbox creation#35356valentinpalkovic wants to merge 1 commit into
Conversation
|
|
View your CI Pipeline Execution ↗ for commit 0ff5d44
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
158e3c6 to
7631bf7
Compare
6eace49 to
5ed0918
Compare
7631bf7 to
a080575
Compare
5ed0918 to
440599f
Compare
Sandbox creation spawned ~24 package-manager subprocesses just to resolve versions, measured via a timestamped local reproduction of angular-vite sandbox creation and confirmed in the CI create-job logs: - latestVersion() probed the registry for every storybook package even though the CLI ships the authoritative version map (versions.ts) and the sandbox registry (verdaccio) serves exactly those versions. Inside sandbox creation (IN_STORYBOOK_SANDBOX, set by the monorepo task runner and never by real user installs) the probe is now short-circuited to the versions map. On CI the resulting specifiers are byte-identical; in link-mode local sandboxes storybook packages get ^version instead of an exact pin, where the linked workspace overrides resolution anyway. - addDependencies(skipInstall) resolved a version for every dependency serially - including dependencies whose specifier already carried one, discarding the result. Lookups now only happen for unversioned specifiers and run concurrently, with insertion order kept deterministic. This also speeds up real 'storybook init' runs. - getInstalledVersion() spawned a full dependency-graph walk per package (yarn info --recursive), which exits 1 with usage output for packages that are not installed at all - addon-vitest probes vitest, msw and coverage packages this way on every sandbox. The module's own package.json is now resolved first (a plain fs read, PnP included), and the graph walk only runs as a fallback for declared dependencies that don't resolve directly (e.g. pnpm virtual store layouts). - The 'sb repro' command probed npm for latest/next before downloading the template; inside sandbox creation those two roundtrips only feed the 'you are behind' warning copy and are skipped. The proxy unit tests asserting registry-probe behavior now stub IN_STORYBOOK_SANDBOX off explicitly - the repo-level .env marks all vitest runs as sandbox context - and a new test pins the short-circuit contract. Measured locally (angular-vite, full creation): 24 -> 8 version-probe spawns; 56s -> 48s on top of the CI-side trims, 107s cumulative baseline.
440599f to
0ff5d44
Compare
|
Pipeline status (workflow The create-job version probes measured as expected: the storybook-package Status note: HEAD needs one pipeline run before undrafting; the last two triggered pipelines were canceled manually, so I've stopped auto-retriggering. Re-trigger via label toggle or push when ready. |
|
HEAD validated green: 82/82 on workflow 069b53d0 (commit 0ff5d44, re-triggered pipeline).
Ready to undraft from my side. |
Ziiyodullayevv
left a comment
There was a problem hiding this comment.
Good optimization. Skipping redundant registry probes during sandbox creation speeds up the initialization process.
Follow-up to #35355 - the product-code half of the angular-create investigation. Sandbox creation spawned ~24 package-manager subprocesses just to resolve versions; most were foregone conclusions.
What
latestVersion()short-circuits to the CLI's ownversions.tsinside sandbox creation (IN_STORYBOOK_SANDBOX, set by the monorepo task runner, never by real user installs). Verdaccio serves exactly those versions andaddPackageResolutionspins them in resolutions regardless, so the per-package registry probe answered a question the CLI already knew. CI specifiers are byte-identical; link-mode local sandboxes get^versioninstead of an exact pin (where the linked workspace overrides resolution anyway).addDependencies(skipInstall)stops resolving versions it throws away: it probed the registry serially for every dependency, including ones whose specifier already carried a version (result discarded). Lookups now happen only for unversioned specifiers and run concurrently with deterministic package.json key order. This speeds up realstorybook initruns too.getInstalledVersion()readsnode_modules/<pkg>/package.jsonfirst (plain fs, PnP included) instead of spawning a full dependency-graph walk per package - a walk that exits 1 with clipanion usage output for packages that aren't installed at all (addon-vitest probes vitest/msw/coverage this way on every sandbox). The graph walk remains as fallback for declared dependencies that don't resolve directly (pnpm virtual stores).sb reproskips its latest/next npm probes inside sandbox creation - they only feed the "you are behind" warning copy there and cost two public-registry roundtrips before the template download starts.Tests
IN_STORYBOOK_SANDBOXoff explicitly - the repo-level.envmarks every vitest run as sandbox context, which is exactly the environment leak that made these tests catch the change.latestVersion('storybook')returns the versions.ts version without spawning.core/common,create-storybook,cli-storybook.Measured (local timestamped E2E, angular-vite full creation)
yarn task sandboxCI create-job step timings will be posted from this PR's pipeline.