Comparison of the errors thrown by libraries, including stack trace length.
import { personSchema } from "./schemas";
import * as v from "valibot";
try {
v.parse(personSchema, data);
} catch (e) {
console.error(e);
}
Where error.stack is available, we measure how many frames it takes to reach the line of user code (as opposed to library code).
ValiError: Invalid length: Expected >=1 but received 0
at Module.parse (file:///node_modules/.pnpm/valibot@1.2.0_typescript@6.0.0-beta/node_modules/valibot/dist/index.mjs:6748:28)
at Object.throw (file:///schemas/dist/benchmarks-D-_Y96Ph.js:93:6)
at file:///bench/src/scripts/stack/log.ts:24:28| Library | Version | Downloads (/wk) | Frame # | Line count | ||||
|---|---|---|---|---|---|---|---|---|
typebox | Code snippet | Error output | 1.1.5 | 204K | 2 | 28 | ||
valibot | Code snippet | Error output | 1.2.0 | 6.6M | 2 | 218 | ||
effect | Code snippet(Commented code is not benchmarked) | Error output | 3.19.19 | 8.3M | 5 | 78 | ||
sury | Code snippet | Error output | 11.0.0-alpha.4 | 148K | 5 | 15 | ||
typia | Code snippet(Commented code is not benchmarked) | Error output | 11.0.3 | 244K | 5 | 13 | ||
effect___beta | Code snippet | Error output | 4.0.0-beta.5 | 8.3M | 7 | 28 | ||
arktype | Code snippet | Error output | 2.1.29 | 972K | 8 | 26 | ||
ajv | Code snippet(Commented code is not benchmarked) | Error output | 8.18.0 | 258M | 16 | |||
joi | Code snippet | Error output | 18.0.2 | 18M | 24 | |||
yup | Code snippet | Error output | 1.7.1 | 10M | 49 | |||
zod | Code snippet | Error output | 4.3.6 | 106M | 171 | |||
zod/mini | Code snippet | Error output | 4.3.6 | 106M | 171 |