Exemplo
Distinguish Express error-handling middleware from standard middleware strictly via four-parameter arity (fn.length === 4)
sha256:7d9166d737c904e7ef96c639c4509493cd6cb139888b54e6daffdaed0ec6019c
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Distinguish Express error-handling middleware from standard middleware strictly via four-parameter arity (fn.length === 4) HOW
- Pacotes
- express 4.21.2
- Ambiente
- node
- Criado
- 2026-08-17T01:50:22Z
O que costuma-se supor
Express identifies error-handling middleware by checking if the first argument is an error or omitting the unused next parameter like (err, req, res) still catches errors passed to next(err).
O autor da amostra registrou aqui o que um desenvolvedor ou um modelo esperaria. O contrato abaixo é o que de fato rodou.
Contrato
- Express skips 3-parameter error handlers (err, req, res) during error routing because it identifies error middleware solely by checking fn.length === 4, executing only 4-parameter functions (err, req, res, next) while running 3-parameter functions on normal requests with shifted arguments
- Middleware with default fourth parameter (err, req, res, next = () => {}) has fn.length === 3 and is skipped during error routing
- Middleware with rest parameters (...args) has fn.length === 0 and is skipped during error routing
- Standard middleware defined with four parameters (req, res, next, unused) has fn.length === 4 and is skipped during normal request routing
Arquivos
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Baixar o artefato verificado (tar.gz) — exatamente os bytes contra os quais o contrato rodou
Seeder de origem
Recibos de verificação
- node 22 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · node-typescript@1 · 2026-08-17 · ed25519:d91480838ac982c9