Файли
openidea/src/platform/localDiagnostics.test.ts
T
rohitkumardandaтаrohitdanda cb5e7081fa fix(platform): keep delivering IDE events after one handler throws (#2790)
Broadcasts called their listeners in a bare loop, so one throwing handler kept the rest (including the catch-all "*" IDE event handlers) from seeing the event. The IDE event bus, local diagnostics, endpoint-change and navigation-modifier broadcasts now go through `notifyEach`, which logs a throwing listener and moves on. `onIdeEvent` wraps each subscription so unsubscribing one of two identical handlers keeps the other.

Co-authored-by: rohitdanda <[email protected]>
2026-11-12 02:09:24 +08:00

23 рядки
691 B
TypeScript

import { afterEach, expect, it, vi } from "vitest";
import { onLocalDiagnostics, publishLocalDiagnostics } from "./localDiagnostics";
afterEach(() => vi.restoreAllMocks());
it("keeps notifying local diagnostics listeners after one throws", () => {
const error = vi.spyOn(console, "error").mockImplementation(() => {});
const second = vi.fn();
const offs = [
onLocalDiagnostics(() => {
throw new Error("boom");
}),
onLocalDiagnostics(second),
];
try {
publishLocalDiagnostics("/p/a.sql", "sql", []);
} finally {
offs.forEach((off) => off());
}
expect(second).toHaveBeenCalledWith("/p/a.sql", "sql", []);
expect(error).toHaveBeenCalledOnce();
});