fix: harden invalidation registry governance
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { isCacheInvalidationTopic } from "./cache-invalidation.ts";
|
||||
import {
|
||||
defineQueryNamespaceIdentity,
|
||||
queryNamespaceIdentityKey,
|
||||
type QueryNamespaceIdentity,
|
||||
} from "./query-keys.ts";
|
||||
@@ -111,8 +112,13 @@ export function indexInvalidationRegistry(
|
||||
const namespaces = new Map<string, QueryNamespaceIdentity>();
|
||||
for (const namespace of registry.namespaces) {
|
||||
let namespaceKey: string;
|
||||
let namespaceSnapshot: QueryNamespaceIdentity;
|
||||
try {
|
||||
namespaceKey = queryNamespaceIdentityKey(namespace);
|
||||
namespaceSnapshot = defineQueryNamespaceIdentity(
|
||||
namespace.namespaceId,
|
||||
namespace.namespaceVersion,
|
||||
);
|
||||
namespaceKey = queryNamespaceIdentityKey(namespaceSnapshot);
|
||||
} catch (error) {
|
||||
throw new TypeError("Invalidation registry namespace is invalid.", {
|
||||
cause: error,
|
||||
@@ -121,7 +127,7 @@ export function indexInvalidationRegistry(
|
||||
if (namespaces.has(namespaceKey)) {
|
||||
throw new TypeError(`Duplicate invalidation namespace: ${namespaceKey}`);
|
||||
}
|
||||
namespaces.set(namespaceKey, namespace);
|
||||
namespaces.set(namespaceKey, namespaceSnapshot);
|
||||
}
|
||||
|
||||
const namespacesForTopic = new Map<string, QueryNamespaceIdentity[]>();
|
||||
|
||||
Reference in New Issue
Block a user