Fix EventEmitter MaxListenersExceededWarning in test suite (SIGINT/SIGTERM)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
- Domain
- testing
Research direction
Start in src/lib/server/ydoc.ts by tracing getYDoc() and resetYDocForTests(), focusing on how SIGINT and SIGTERM listeners are registered and reset. Run npm run test:coverage and confirm the full test suite no longer prints MaxListenersExceededWarning messages.
Written by the indexing model from the issue text.
Description
Noticed while working on #34 (PR #57) — every full test run prints:
```
(node:XXXXX) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. MaxListeners is 10.
(node:XXXXX) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. MaxListeners is 10.
```
Cause: `src/lib/server/ydoc.ts`'s `getYDoc()` calls `process.once('SIGINT', shutdown)` / `process.once('SIGTERM', shutdown)` on first access, but each test file that calls `resetYDocForTests()` and then `getYDoc()` again creates a fresh `YDocState` and registers a new pair of listeners — the old ones are never removed (`process.off`/`removeListener` is never called). Across enough test files in one Vitest worker process, this crosses Node's default max-listener warning threshold (10).
Not currently causing test failures, just console noise, but it's a real (if small) leak: harmless in a real server process (this only happens once, at real startup), but indicates resetYDocForTests() should probably also deregister the previous state's shutdown listeners, not just clear the Y.Doc/timer/audit-observer state.
Proposal
- Track the registered
shutdownlistener (or make it idempotent via a stored reference) inYDocState, and remove it inresetYDocForTests()before creating a new one - Verify the warning is gone from a full
npm run test:coveragerun
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 1
- Avg merge
- 3h 53m
- Merged PRs (30d)
- 124
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from brylie/compendium
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
brylie/compendium#313 · 2 comments ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
brylie/compendium#294 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
brylie/compendium#267 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
brylie/compendium#250 · 1 comment ·
-
enhancement help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
brylie/compendium#233 · 2 comments ·
All issues in brylie/compendium
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100