ajv-validator / ajv-validator/ajv

v7: schema compilation is safer but significantly slower than v6 - using standalone validation code

Offen
#1,386 6 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
docs
Vorherrschende Sprache
TypeScript
Sterne
14.8k
Forks
1k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

In Serverless Framework we've just upgrade AJV from v6 to v7, and observed that `ajv.compile(schema)` execution time for very same schema jumped from ca `0.15s` to `0.8s`.

Is this a known issue?

It can be observed by running any Serverless Framework command, and measuring execution time at this line:

https://github.com/serverless/serverless/blob/bcbbd47fa09b7d99d7f8da3f11150215d1203bba/lib/classes/ConfigSchemaHandler/index.js#L106

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

v7.0.3

**Ajv options object**

```javascript
{ allErrors: true, coerceTypes: 'array', verbose: true, strict: false }
```

**JSON Schema**

It's a large dynamically generated schema, if needed I can export it to JSON and provide a link

**Your code**

```javascript
const Ajv = require('ajv').default;
const ajv = new Ajv({ allErrors: true, coerceTypes: 'array', verbose: true, strict: false });
ajv.compile(schema);
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.