Skip to content

🧪 fix(logging): unref StructuredLogger interval — jest teardown leak 제거#38

Merged
jlinsights merged 2 commits into
mainfrom
fix/jest-teardown-leak
Jun 15, 2026
Merged

🧪 fix(logging): unref StructuredLogger interval — jest teardown leak 제거#38
jlinsights merged 2 commits into
mainfrom
fix/jest-teardown-leak

Conversation

@jlinsights

@jlinsights jlinsights commented Jun 15, 2026

Copy link
Copy Markdown
Owner

문제

npm run test:ci 매 실행마다 "A worker process has failed to exit gracefully ... improper teardown" 경고. jest --detectOpenHandles 결과 6개 open handle 전부 동일 원인StructuredLoggersetInterval. CI flaky 잠재 요인.

근본 원인

lib/logging/structured-logger.ts:435 export const logger = StructuredLogger.getInstance()모듈 import 시점에 인스턴스화 → constructor → startProcessing()(397) setInterval(processQueue, 100ms). logger를 (transitive) import하는 테스트들에서 이 타이머가 안 꺼져 jest가 종료를 못 함. child logger도 동일.

수정 (기능 코드 1파일, 프로덕션 무변경)

startProcessing()의 interval에 .unref() (브라우저 안전 typeof 가드) 추가 → 타이머가 Node 프로세스 종료를 막지 않게 함. 실행 중 100ms 큐 처리는 그대로 동작. startProcessing 단일 경로라 singleton+child logger 일괄 해결.

검증

  • jest --detectOpenHandles: "Jest has detected ... open handles" 사라짐 (6 → 0)
  • test:ci: exit 0 · 389/389 pass · force-exit 경고 0
  • tsc --noEmit 0 · lint 0 errors (10 max-lines warning 불변)

Test plan

  • CI check job green (e2e는 pre-existing Clerk 키 인프라 블로커 — 본 PR 무관)

PDCA: asca-jest-teardown-leak (Plan+Do 완료). 머지 후 report→archive.

Summary by CodeRabbit

릴리스 노트

  • Bug Fixes

    • Jest 테스트 중 워커 프로세스 정상 종료 문제 해결 - 로깅 시스템의 주기적 타이머가 프로세스 종료를 방해하지 않도록 개선했습니다.
  • Documentation

    • 테어다운 누수 이슈 및 해결 방안에 대한 계획 문서 추가

…leak

StructuredLogger's processing setInterval (started at module load via the
`logger` singleton -> constructor -> startProcessing) was never cleared in
tests, keeping jest from exiting -> 'A worker process has failed to exit
gracefully' on every test:ci run (6 open handles via --detectOpenHandles,
all the same StructuredLogger setInterval). Potential CI flakiness.

Fix: call .unref() on the interval (guarded by typeof for browser safety)
so the timer no longer keeps the Node process alive. Production behavior
unchanged — the 100ms queue processing still runs while the app is live;
child loggers go through the same startProcessing so they're covered too.

Verify: jest --detectOpenHandles reports 0 handles (was 6), test:ci exits 0
with 389/389 passing and no force-exit warning, tsc/lint clean.

PDCA: asca-jest-teardown-leak (do).
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
asca-main Ready Ready Preview, Comment Jun 15, 2026 5:10am

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jlinsights, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 51 minutes and 54 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e207d60e-79ef-4389-a30d-1592fc5312da

📥 Commits

Reviewing files that changed from the base of the PR and between 034b033 and cc5d555.

📒 Files selected for processing (1)
  • docs/01-plan/features/asca-jest-teardown-leak.plan.md

Note

.coderabbit.yml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized keys: "rules", "include", "exclude", "prompts", "integrations", "severity", "ai_validation"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

StructuredLogger.startProcessing()setInterval 타이머에 unref() 호출을 추가해 Jest 워커 teardown 누수를 제거한다. 관련 플랜 문서가 신규 추가되고, .bkit-memory.json.commit_message.txt가 현재 작업 상태로 갱신된다.

Changes

Jest Teardown 누수 수정

Layer / File(s) Summary
setInterval unref() 수정 및 플랜 문서
lib/logging/structured-logger.ts, docs/01-plan/features/asca-jest-teardown-leak.plan.md
startProcessing() 내부 setInterval 반환값에 typeof unref === 'function' 가드 후 processingInterval.unref()를 호출해 프로세스 종료를 차단하지 않도록 조정. 플랜 문서에는 --detectOpenHandles로 확인한 근본 원인, 성공 기준, 브라우저 호환 리스크 완화 방안이 포함됨.
도구 메타데이터 및 커밋 메시지 갱신
.bkit-memory.json, .commit_message.txt
activeFeatureasca-jest-teardown-leak으로, phasedo로 변경하고 parallelFeatures 실행 기록을 추가. 커밋 메시지를 이번 수정 내용으로 교체.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 주요 변경 사항을 명확하게 요약하고 있으며, StructuredLogger의 interval unref 처리를 통한 Jest teardown leak 제거라는 핵심 의도를 효과적으로 전달합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/jest-teardown-leak

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jlinsights jlinsights merged commit 3579151 into main Jun 15, 2026
9 checks passed
@jlinsights jlinsights deleted the fix/jest-teardown-leak branch June 15, 2026 05:16
jlinsights added a commit that referenced this pull request Jun 15, 2026
PR #38 squash 3579151, CI all green. plan + report moved to
docs/archive/2026-06/asca-jest-teardown-leak/, 2026-06 _INDEX created,
.bkit-memory phase=archived. StructuredLogger setInterval .unref() fixed
jest 'worker failed to exit gracefully' teardown leak (detectOpenHandles
6 -> 0). Docs only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant