ajv-validator / ajv-validator/ajv

compileAsync causes infinite chain of requests when metaschema is specified

Open
#1,821 2 comments 0 reactions 0 assignees View on GitHub
bug report limitation
Dominant language
TypeScript
Stars
14.8k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

**What version of Ajv are you using? 8.8
Does the issue happen if you use the latest version? yes**

**Ajv options object**

```javascript
{
loadSchema: async (url) => {
if (url.startsWith("http://")) {
url = "https://" + url.substring(7)
}
const ans = await (await fetch(url)).json()
console.log(ans)
return ans;
}
}

```

**JSON Schema**

```json
{ "$ref": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#" }
```

**Sample data**

The schema never finishes compiling

**Your code**

```javascript
const ajv = new Ajv(options)

async function compile() {
await ajv.compileAsync(schema)
console.log("Done compiling")
}

```
Here's a sandbox replicating the problem: https://runkit.com/yesennes/619429f6e904c40008bcc644

**Validation result, data AFTER validation, error messages**

```
The schema never finish compiling.
```

**What results did you expect?**
The schema to finish compiling.
**Are you going to resolve the issue?**
I can take a stab at it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.