import type { CleanupScope } from "./CleanupScope.ts"; export const assertNoLeaks = ( scope: CleanupScope, extra: readonly { readonly kind: string; readonly id: string }[] = [], ): void => { const leaks = [...scope.pending(), ...scope.liveResources(), ...extra]; if (leaks.length) throw Object.assign(new Error(`CLEANUP_LEAK: ${leaks.map((x) => `${x.kind}/${x.id}`).join(", ")}`), { code: "CLEANUP_LEAK", details: { leaks }, }); };