Repository navigation
fix(logger): skip pino-pretty transport in tests (closes #2541) - #2543
Merged
Merged
Conversation
The pino-pretty transport spawns a worker thread and registers
process.on('exit', ...), which holds the event loop open at vitest
teardown — resulting in zombie workers that could hang pre-commit for
hours. 37 such processes had accumulated across Conductor workspaces,
some running 2 days at 0% CPU.
Treat NODE_ENV=test and VITEST=true (auto-set by vitest) as non-dev so
tests use the default synchronous stdout destination with no worker
thread and no exit listener. Six back-to-back runs confirm the hang is
eliminated.
The defensive timeout wrapper and threads pool from #2542 stay as
belt-and-suspenders against future regressions.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server/src/logger.tsenabled thepino-prettytransport wheneverNODE_ENV !== 'production'. Pino's transport spawns a worker thread and registersprocess.on('exit', ...)(seenode_modules/pino/lib/transport.js:149) — the worker thread is a held handle that prevents Node's event loop from draining at test teardown, causing vitest workers to zombie indefinitely.NODE_ENV=testandVITEST=true(auto-set by vitest) as non-dev so tests use the default synchronous stdout destination — no worker thread, no exit listener.Evidence
Hypothesis test — 4 back-to-back runs of
npm run test:unit:NODE_ENV=dev)NODE_ENV=productionZero
MaxListenersExceededWarningafter the fix (previously consistently emitted: "11 exit listeners added to [process]").Related
The defensive timeout wrapper and
--pool=threadsfrom #2542 stay as belt-and-suspenders against future dependency regressions.Test plan
npm run test:unit— 587 tests pass in ~1.5snpm run typecheck— passes🤖 Generated with Claude Code