perf(plugins): add O(1) fast-path for empty plugin loads · openclaw/openclaw@1c45592
medns
·
2026-04-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3285,6 +3285,39 @@ module.exports = { id: "throws-after-import", register() {} };`,
|
3285 | 3285 | expect(registry.plugins).toEqual([]); |
3286 | 3286 | }); |
3287 | 3287 | |
| 3288 | +it("skips discovery and manifest registry loading entirely when onlyPluginIds is an explicit empty array", async () => { |
| 3289 | +useNoBundledPlugins(); |
| 3290 | +const allowed = writePlugin({ |
| 3291 | +id: "allowed-empty-scope", |
| 3292 | +filename: "allowed-empty-scope.cjs", |
| 3293 | +body: `module.exports = { id: "allowed-empty-scope", register() {} };`, |
| 3294 | +}); |
| 3295 | + |
| 3296 | +const discovery = await import("./discovery.js"); |
| 3297 | +const manifestRegistry = await import("./manifest-registry.js"); |
| 3298 | +const discoverySpy = vi.spyOn(discovery, "discoverOpenClawPlugins"); |
| 3299 | +const manifestSpy = vi.spyOn(manifestRegistry, "loadPluginManifestRegistry"); |
| 3300 | + |
| 3301 | +const registry = loadOpenClawPlugins({ |
| 3302 | +cache: false, |
| 3303 | +activate: false, |
| 3304 | +config: { |
| 3305 | +plugins: { |
| 3306 | +load: { paths: [allowed.file] }, |
| 3307 | +allow: ["allowed-empty-scope"], |
| 3308 | +}, |
| 3309 | +}, |
| 3310 | +onlyPluginIds: [], |
| 3311 | +}); |
| 3312 | + |
| 3313 | +expect(registry.plugins).toEqual([]); |
| 3314 | +expect(discoverySpy).not.toHaveBeenCalled(); |
| 3315 | +expect(manifestSpy).not.toHaveBeenCalled(); |
| 3316 | + |
| 3317 | +discoverySpy.mockRestore(); |
| 3318 | +manifestSpy.mockRestore(); |
| 3319 | +}); |
| 3320 | + |
3288 | 3321 | it("only publishes plugin commands to the global registry during activating loads", async () => { |
3289 | 3322 | useNoBundledPlugins(); |
3290 | 3323 | const plugin = writePlugin({ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。