The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 22:15 UTC
fix(provider-core): isolate npm version caches by lookup environment (#34309)
Romil committed
Nov 12, 2026 at 10:23 UTC
62e68f3166880362e54b4d277e66da901f629a34
2 files changed
+67
packages/provider-core/src/server/maintenanceResolver.test.ts
+51
@@ -421,6 +421,57 @@ it.layer(
421
{ skip: !symlinksSupported || windowsHost },
422
);
423
424
+ it.effect.skipIf(!symlinksSupported || windowsHost)(
425
+ "keeps configured npm registries' latest versions apart for one install",
426
+ () =>
427
+ Effect.gen(function* () {
428
+ const tempDir = yield* makeTempDir("t3-npm-registry-isolation");
429
+ yield* Effect.addFinalizer(() =>
430
+ Effect.sync(() => NodeFS.rmSync(tempDir, { recursive: true, force: true })),
431
+ );
432
+ const npmBinDir = NodePath.join(tempDir, "npm-bin");
433
+ writeExecutable(NodePath.join(npmBinDir, "npm"));
434
+ const binaryPath = linkIntoPackage(tempDir, "package-tool", [
435
+ "lib",
436
+ "node_modules",
437
+ "@example",
438
+ "package-tool",
439
+ ]);
440
+ let probes = 0;
441
+ const latest = (registry: string, version: string) =>
442
+ resolveProviderMaintenanceCapabilitiesEffect(packageToolUpdate, {
443
+ binaryPath,
444
+ env: { PATH: npmBinDir, NPM_CONFIG_REGISTRY: registry },
445
+ }).pipe(
446
+ Effect.provideService(
447
+ ChildProcessSpawner.ChildProcessSpawner,
448
+ stdoutSpawner(() => {
449
+ probes++;
450
+ return JSON.stringify(version);
451
+ }),
452
+ ),
453
+ Effect.tap((capabilities) =>
454
+ Effect.sync(() => {
455
+ expect(capabilities.latestVersionCacheKey ?? "").not.toContain("private-token");
456
+ }),
457
+ ),
458
+ Effect.flatMap(resolveLatestProviderVersion),
459
+ );
460
+ const first = "https://user:private-token@first.example.test";
461
+ const second = "https://second.example.test";
462
+ expect(yield* latest(first, "1.1.0")).toBe("1.1.0");
463
+ expect(yield* latest(second, "2.0.0")).toBe("2.0.0");
464
+ expect(yield* latest(first, "1.2.0")).toBe("1.1.0");
465
+ expect(probes).toBe(2);
466
+ }).pipe(
467
+ Effect.provide(ProviderLatestVersions.layer),
468
+ Effect.provideService(
469
+ HttpClient.HttpClient,
470
+ HttpClient.make(() => Effect.die("configured registries must not use public npm")),
471
+ ),
472
+ ),
473
+ );
474
+
475
it("pins the advertised stable version in a pnpm-global update command", () => {
476
const advisoryFor = (
477
maintenanceCapabilities: ReturnType<typeof makeProviderMaintenanceCapabilities>,
packages/provider-core/src/server/maintenanceResolver.ts
+16
@@ -938,6 +938,14 @@ const decodeNpmViewVersion = Schema.decodeUnknownOption(
938
Schema.fromJsonString(Schema.Union([Schema.String, Schema.Tuple([Schema.String])])),
939
);
940
941
+function environmentCacheKey(env: NodeJS.ProcessEnv): string {
942
+ return NodeCrypto.createHash("sha256")
943
+ .update(
944
+ JSON.stringify(Object.entries(env).toSorted(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))),
945
+ )
946
+ .digest("hex");
947
+}
948
+
949
const withConfiguredNpmVersionLookup = Effect.fn("withConfiguredNpmVersionLookup")(function* (
950
capabilities: ProviderMaintenanceCapabilities,
951
) {
@@ -981,6 +989,14 @@ const withConfiguredNpmVersionLookup = Effect.fn("withConfiguredNpmVersionLookup
989
...capabilities,
990
// npm owns registry, scoped auth and proxy configuration; failure must not retry public npm.
991
latestVersion: null,
992
+ latestVersionCacheKey: [
993
+ "configured-npm",
994
+ npmPath,
995
+ packageName,
996
+ prefix ?? "",
997
+ environmentCacheKey(env),
998
+ installerLatestVersionKey(capabilities) ?? "",
999
+ ].join("\0"),
1000
lookupLatestVersion: capabilities.lookupLatestVersion
1001
? capabilities.lookupLatestVersion.pipe(
1002
Effect.filterOrElse(