Comparison of the errors thrown by libraries, including stack trace length.
Copy to clipboardimport { 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 | ||||
|---|---|---|---|---|---|---|---|---|
zod/v3 | Code snippet | Error output | 4.4.3 | 194.82M | 299 | |||
valibot | Code snippet | Error output | 1.4.1 | 12.23M | 218 | |||
zod | Code snippet | Error output | 4.4.3 | 194.82M | 171 | |||
zod/mini | Code snippet | Error output | 4.4.3 | 194.82M | 171 | |||
decoders | Code snippet | Error output | 2.9.3 | 65.99K | 98 | |||
@sapphire/shapeshift | Code snippet | Error output | 4.0.0 | 908.74K | 90 | |||
effect | Code snippet(Commented code is not benchmarked) | Error output | 3.21.2 | 18.8M | 78 | |||
yup | Code snippet | Error output | 1.7.1 | 12.32M | 49 | |||
runtypes | Code snippet | Error output | 7.0.4 | 316.01K | 37 | |||
sury | Code snippet(Commented code is not benchmarked) | Error output | 11.0.0-alpha.7 | 190.35K | 36 | |||
superstruct | Code snippet | Error output | 2.0.2 | 5.3M | 29 | |||
typebox | Code snippet | Error output | 1.1.39 | 4.48M | 28 | |||
arktype | Code snippet | Error output | 2.2.0 | 1.15M | 26 | |||
joi | Code snippet | Error output | 18.2.1 | 22.49M | 24 | |||
effect@beta | Code snippet | Error output | 4.0.0-beta.75 | 18.8M | 22 | |||
ajv | Code snippet(Commented code is not benchmarked) | Error output | 8.20.0 | 320.75M | 16 | |||
typia | Code snippet(Commented code is not benchmarked) | Error output | 12.1.1 | 319.65K | 15 |