Skip to content

Commit cc4375f

Browse files
committed
fix: respect disabled persisted plugin registry reads
1 parent 771d03a commit cc4375f

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

src/plugins/plugin-registry-snapshot.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ function resolvePluginRegistrySnapshotMemoKey(
136136
if (!canMemoizePluginRegistrySnapshot(params)) {
137137
return undefined;
138138
}
139+
const persistedReadsEnabled =
140+
params.preferPersisted !== false && !hasEnvFlag(env, DISABLE_PERSISTED_PLUGIN_REGISTRY_ENV);
141+
const persistedRegistryFingerprint = persistedReadsEnabled
142+
? hashJson(
143+
readPersistedInstalledPluginIndexSync({
144+
env,
145+
...(params.stateDir ? { stateDir: params.stateDir } : {}),
146+
}),
147+
)
148+
: "disabled";
139149
return hashJson({
140150
config: params.config ?? null,
141151
cwd: process.cwd(),
@@ -144,12 +154,7 @@ function resolvePluginRegistrySnapshotMemoKey(
144154
preferPersisted: params.preferPersisted ?? null,
145155
// Plugin manifests are process-stable inside the Gateway, while the persisted
146156
// registry envelope can change through explicit refresh/install flows.
147-
registry: hashJson(
148-
readPersistedInstalledPluginIndexSync({
149-
env,
150-
...(params.stateDir ? { stateDir: params.stateDir } : {}),
151-
}),
152-
),
157+
registry: persistedRegistryFingerprint,
153158
pluginRoots: fingerprintPluginSourceRoots(params, env),
154159
stateDir: params.stateDir ? resolveUserPath(params.stateDir, env) : null,
155160
workspaceDir: params.workspaceDir ? resolveUserPath(params.workspaceDir, env) : null,
@@ -440,7 +445,7 @@ export function loadPluginRegistrySnapshotWithMetadata(
440445
const disabledByCaller = params.preferPersisted === false;
441446
const disabledByEnv = hasEnvFlag(env, DISABLE_PERSISTED_PLUGIN_REGISTRY_ENV);
442447
const persistedReadsEnabled = !disabledByCaller && !disabledByEnv;
443-
const persistedInstallRecordReadsEnabled = !disabledByEnv;
448+
const persistedInstallRecordReadsEnabled = persistedReadsEnabled;
444449
let persistedIndex: InstalledPluginIndex | null;
445450
if (persistedInstallRecordReadsEnabled) {
446451
persistedIndex = readPersistedInstalledPluginIndexSync(params);

src/plugins/plugin-registry.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ describe("plugin registry facade", () => {
873873
expectSnapshotPluginIds(result.snapshot, ["demo"]);
874874
});
875875

876-
it("derives a fresh registry without dropping persisted install records", async () => {
876+
it("derives a fresh registry without persisted install records when caller disables persisted reads", async () => {
877877
const stateDir = makeTempDir();
878878
const rootDir = makeTempDir();
879879
const candidate = createCandidate(rootDir);
@@ -899,10 +899,7 @@ describe("plugin registry facade", () => {
899899

900900
expect(result.source).toBe("derived");
901901
expectSnapshotPluginIds(result.snapshot, ["demo"]);
902-
expectInstallRecord(result.snapshot.installRecords, "persisted", {
903-
source: "npm",
904-
905-
});
902+
expect(result.snapshot.installRecords).not.toHaveProperty("persisted");
906903
});
907904

908905
it("exposes explicit persisted registry inspect and refresh operations", async () => {

0 commit comments

Comments
 (0)