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 | ||||
|---|---|---|---|---|---|---|---|---|
@sapphire/shapeshift | Code snippet | Error output | 4.0.0 | 642.42K | 90 | |||
ajv | Code snippet(Commented code is not benchmarked) | Error output | 8.18.0 | 251.75M | 16 | |||
arktype | Code snippet | Error output | 2.2.0 | 869.14K | 26 | |||
decoders | Code snippet | Error output | 2.9.2 | 42.73K | 98 | |||
effect | Code snippet(Commented code is not benchmarked) | Error output | 3.21.0 | 8.99M | 78 | |||
effect@beta | Code snippet | Error output | 4.0.0-beta.43 | 8.99M | 28 | |||
joi | Code snippet | Error output | 18.1.2 | 17.37M | 24 | |||
runtypes | Code snippet | Error output | 7.0.4 | 256.41K | 37 | |||
superstruct | Code snippet | Error output | 2.0.2 | 3.93M | 29 | |||
sury | Code snippet | Error output | 11.0.0-alpha.4 | 111.6K | 15 | |||
typebox | Code snippet | Error output | 1.1.14 | 231.35K | 28 | |||
typia | Code snippet(Commented code is not benchmarked) | Error output | 12.0.2 | 234.4K | 15 | |||
valibot | Code snippet | Error output | 1.3.1 | 7.13M | 218 | |||
yup | Code snippet | Error output | 1.7.1 | 10.02M | 49 | |||
zod | Code snippet | Error output | 4.3.6 | 139.49M | 171 | |||
zod/mini | Code snippet | Error output | 4.3.6 | 139.49M | 171 | |||
zod/v3 | Code snippet | Error output | 4.3.6 | 139.49M | 299 |