mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:50:43 +00:00
fix: tolerate bundled channel catalog discovery failures
This commit is contained in:
28
src/channels/bundled-channel-catalog-read.fail-soft.test.ts
Normal file
28
src/channels/bundled-channel-catalog-read.fail-soft.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
describe("listBundledChannelCatalogEntries discovery failures", () => {
|
||||
it("falls back when bundled plugin catalog discovery is unavailable during import", async () => {
|
||||
vi.doMock("../infra/openclaw-root.js", () => ({
|
||||
resolveOpenClawPackageRootSync: () => null,
|
||||
resolveOpenClawPackageRoot: async () => null,
|
||||
}));
|
||||
vi.doMock("../plugins/channel-catalog-registry.js", () => ({
|
||||
listChannelCatalogEntries() {
|
||||
throw new ReferenceError("Cannot access 'discoverOpenClawPlugins' before initialization.");
|
||||
},
|
||||
}));
|
||||
|
||||
const catalog = await importFreshModule<typeof import("./bundled-channel-catalog-read.js")>(
|
||||
import.meta.url,
|
||||
"./bundled-channel-catalog-read.js?scope=discovery-fail-soft",
|
||||
);
|
||||
|
||||
expect(catalog.listBundledChannelCatalogEntries()).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -28,7 +28,11 @@ function listPackageRoots(): string[] {
|
||||
}
|
||||
|
||||
function readBundledExtensionCatalogEntriesSync(): PluginPackageChannel[] {
|
||||
return listChannelCatalogEntries({ origin: "bundled" }).map((entry) => entry.channel);
|
||||
try {
|
||||
return listChannelCatalogEntries({ origin: "bundled" }).map((entry) => entry.channel);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function readOfficialCatalogFileSync(): ChannelCatalogEntryLike[] {
|
||||
|
||||
Reference in New Issue
Block a user