Skip to content

Commit edbd7e8

Browse files
committed
Make retrieving meta-schemas more robust
1 parent cd62e74 commit edbd7e8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ subscribe("validate.metaValidate", async (_message, schema) => {
4343

4444
// Compile
4545
if (!(schema.document.dialectId in metaValidators)) {
46-
const metaSchema = await getSchema(schema.document.dialectId);
46+
const metaSchema = await getSchema(schema.document.dialectId, schema);
4747
const compiledSchema = await compile(metaSchema);
4848
metaValidators[schema.document.dialectId] = interpret(compiledSchema);
4949
}

lib/schema.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ const schemaRegistry = {};
2222
export const getSchema = async (uri, browser = undefined) => {
2323
if (!browser) {
2424
browser = { _cache: {} };
25+
}
2526

26-
for (const uri in schemaRegistry) {
27+
for (const uri in schemaRegistry) {
28+
if (!(uri in browser._cache)) {
2729
browser._cache[uri] = schemaRegistry[uri];
2830
}
2931
}
3032

31-
const schema = await browserGet(uri, browser);
33+
const schema = await browserGet(uri, { ...browser });
3234
if (typeof schema.document.dialectId !== "string") {
3335
throw Error(`The document at ${schema.document.baseUri} is not a schema.`);
3436
}

0 commit comments

Comments
 (0)