Skip to content

fix(core): pm2 peer 범위 확대 및 optional 전환#20

Merged
myamaak merged 3 commits into
mainfrom
fix/core-pm2-peer-range
Jul 14, 2026
Merged

fix(core): pm2 peer 범위 확대 및 optional 전환#20
myamaak merged 3 commits into
mainfrom
fix/core-pm2-peer-range

Conversation

@myamaak

@myamaak myamaak commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Describe your changes

packages/core의 pm2 peer dependency를 수정

  • peer 범위 확대: >=5.3.0 <6.0.0>=5.3.0
    • 상한(<6.0.0)을 제거해 pm2 6.x·7.x 사용 환경에서도 호환되도록 수정
  • optional 전환: peerDependenciesMeta.pm2.optional: true 추가
    • pm2는 클러스터 모드 사용 시에만 필요하므로 선택적 의존성으로 변경
    • pm2를 사용하지 않는 프로젝트에서 발생하던 불필요한 peer warning / 강제 설치 문제 해소

@myamaak myamaak self-assigned this Jul 9, 2026
@npayfebot

npayfebot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

✅ Changeset detected

Latest commit: 9ffd0c1

@naverpay/prometheus-core package have detected changes.

If no version change is needed, please add skip-detect-change to the label.

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@naverpay/prometheus-core ✨ Minor
@naverpay/prometheus-hono 🐛 Patch
@naverpay/prometheus-koa 🐛 Patch
@naverpay/prometheus-next 🐛 Patch
powered by: naverpay changeset detect-add actions

@myamaak
myamaak marked this pull request as ready for review July 9, 2026 05:00
2-one-week
2-one-week previously approved these changes Jul 13, 2026

@2-one-week 2-one-week left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다~

@arale-dev arale-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다!

dayoung-nam and others added 2 commits July 13, 2026 14:43
pm2 상한(<6.0.0)을 제거해 ReDoS 패치 버전(6.0.14/7.x) 설치를 허용하고,
pm2 미사용 환경을 위해 optional peer로 전환.
@myamaak

myamaak commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

@2-one-week 님, @arale-dev 님, 이전 pr 머지하느라 컨플릭트가 있었는데 다시 한번만 승인 부탁드리겠습니다!

@kyungmi kyungmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pm2 peer 범위를 넓히고 optional로 전환한 의도는 명확한데, 실제 런타임에서 optional이 지켜지는지 확인하다가 걸리는 부분을 하나 남겼습니다.

  • [issue] 1건 — pm2/promisify.ts의 top-level import로 인해 pm2 미설치 시 여전히 런타임 크래시 가능성

},
"peerDependenciesMeta": {
"pm2": {
"optional": true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[issue] optional: true 설정만으로는 pm2 미설치 환경에서의 강제 설치/크래시 문제가 실제로 해소되지 않는 것 같습니다.

  • packages/core/src/pm2/promisify.tsimport pm2 from 'pm2'가 top-level로 있고, src/index.tspm2/promisify.tspm2/messages.ts를 무조건 re-export하고 있습니다.
  • Node 런타임(번들러 tree-shaking이 적용되지 않는 서버 환경)에서는 @naverpay/prometheus-koa(또는 hono/next)를 import만 해도 core의 index.ts를 거쳐 pm2/promisify.ts가 즉시 로드되고, 그 안의 import pm2 from 'pm2'가 실행됩니다.
  • 이 상태에서 pm2가 node_modules에 없으면 peerDependenciesMeta.pm2.optional: true와 무관하게 Cannot find module 'pm2'로 즉시 크래시됩니다. optional: true는 pnpm/npm의 peer warning만 제거해줄 뿐, 런타임 로딩 문제는 그대로인 것 같습니다.

근거: PR 설명에서 목표로 삼은 "pm2 사용 안 하는 프로젝트의 강제 설치 문제 해소"가 peer 범위·optional 플래그 조정만으로는 실제로 달성되지 않고, pm2 미설치 상태로 다른 패키지를 사용하면 여전히 런타임 에러가 발생할 것으로 보입니다.

이점: pm2 관련 모듈(pm2/promisify.ts, pm2/messages.ts)을 동적 import로 전환해 pm2Connector.connect() 호출 시점에만 로드하거나, subpath export로 분리하면 pm2 미사용 프로젝트에서 설치 없이도 나머지 기능을 안전하게 사용할 수 있습니다.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional 전환이 이 PR의 주요한 목적이 아니었다면 그냥 넘어가셔도 무방할 것 같아요.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyungmi 님, 겸사겸사 챙긴거긴 했는데요, 설치할때 말고 import할때도 문제되지 않도록 해주는게 더 좋을 것 같아서 이번에 수정해주었습니다! 한번만 더 확인 부탁드려요!

@arale-dev arale-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다!

promisify.ts/types.ts에서 pm2의 ProcessDescription을 직접 import하던 부분을
로컬 PM2ProcessDescription(name, pm_id)으로 대체. pm2를 설치하지 않은
소비자가 skipLibCheck: false로 타입체크할 때 Cannot find module 'pm2'
에러가 나던 문제 해소.

@kyungmi kyungmi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

top-level import를 lazy loading으로 바꿔서 pm2 미설치 환경에서도 import 시점 크래시가 안 나도록 확실히 잡아주셨네요.

  • pm2/promisify.ts top-level import pm2 from 'pm2' 문제 — loadPm2()await import('pm2') 지연 로딩 전환, types.ts도 pm2 타입 의존 제거로 커밋 확인

@myamaak
myamaak merged commit 5749566 into main Jul 14, 2026
4 checks passed
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.

5 participants