Skip to content

Commit d2e62c6

Browse files
fix(diffs): stop lightweight CLI registration from crashing when runtime.state is unavailable (#128360)
* fix(diffs): stop lightweight CLI registration from crashing The diffs plugin has no cli-metadata.ts, so the lightweight CLI metadata loader fell back to plugin.ts and called register() with an empty runtime, crashing on api.runtime.state.openBlobStore for any non-bundled install (e.g. the published @openclaw/diffs npm package). Add a no-op cli-metadata.ts, matching every other bundled plugin's convention, so CLI metadata capture stops there instead of loading the full runtime. Fixes #128330 * fix(diffs): skip runtime setup while collecting CLI metadata --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent cbd4841 commit d2e62c6

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎extensions/diffs/src/plugin.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ afterAll(() => {
2020
});
2121

2222
describe("diffs plugin language-pack discovery", () => {
23+
it("skips runtime registration while collecting CLI metadata", () => {
24+
const registerTool = vi.fn();
25+
const registerHttpRoute = vi.fn();
26+
const on = vi.fn();
27+
const api = createTestPluginApi({
28+
registrationMode: "cli-metadata",
29+
registerTool,
30+
registerHttpRoute,
31+
on,
32+
});
33+
34+
expect(() => registerDiffsPlugin(api)).not.toThrow();
35+
expect(registerTool).not.toHaveBeenCalled();
36+
expect(registerHttpRoute).not.toHaveBeenCalled();
37+
expect(on).not.toHaveBeenCalled();
38+
});
39+
2340
it.each(["assets", "dist/assets"])(
2441
"requires both the sibling manifest and generated runtime asset in %s",
2542
(assetDir) => {

‎extensions/diffs/src/plugin.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ const DIFF_ARTIFACT_MAX_BYTES_PER_ENTRY = 32 * 1024 * 1024;
2525
const DIFF_ARTIFACT_MAX_BYTES_PER_NAMESPACE = 256 * 1024 * 1024;
2626

2727
export function registerDiffsPlugin(api: OpenClawPluginApi): void {
28+
// CLI metadata has no runtime state, and this plugin exposes no CLI commands.
29+
if (api.registrationMode === "cli-metadata") {
30+
return;
31+
}
32+
2833
const store = new DiffArtifactStore({
2934
rootDir: path.join(resolvePreferredOpenClawTmpDir(), "openclaw-diffs"),
3035
blobStore: api.runtime.state.openBlobStore<DiffArtifactBlobMetadata>({

0 commit comments

Comments
 (0)