Skip to main content

Anti-Patterns

Anti-patternSymptomRiskBetter design
sync fs in request pathlatency spikesblocks all callbacksasync/stream/preload
CPU loop on main threadevent-loop lagprocess-wide latencybetter algorithm / worker pool
huge Promise.allmemory/pool spikeoverloadbounded concurrency
giant controllerhard tests/changesmixed concernstransport → use case → adapters
giant utils/hidden ownershipcouplingdomain/capability modules
singleton mutable statecross-request bugsreplica inconsistencyscoped state / authoritative store
process.env everywherehidden dependenciesinvalid config at runtimeparse once + inject
no runtime validationweird deep failuressecurity/data corruptionvalidate at boundary
no cancellationtimed-out work continuesresource leakpropagate AbortSignal/driver cancel
no timeoutsinfinite in-flight workcascading failuredeadline budgets
retry without idempotencyduplicate effectsmoney/data bugsidempotency keys + atomic storage
catch and ignoresilent failureinconsistent stateown/translate/rethrow
process.exit in libraryabrupt host deathdata/log lossreturn error / app owns lifecycle
cluster as architecturehidden process coordinationoperational complexityexternal replicas / explicit workers
DB model = public APIstorage changes break clientscoupling/leakageDTO/schema boundary
excessive middlewareinvisible control flowdebugging/security gapsexplicit use cases
log secretscredential exposurebreachredact/allowlist logging
EventEmitter everywherehidden flowleak/error/order issuesdirect calls/domain events/durable broker
premature workerscomplexity/no gainoverheadprofile first
framework-driven architecturedomain tied to adaptersmigration/testing painstable application/domain boundaries

Review method​

When you see one of these, ask four questions: what is the symptom, why did the code evolve this way, what production risk does it create, and what is the smallest design change that restores ownership/bounds?