Repository navigation
fix: better-sqlite3 로드 격리 및 13.0.3 업그레이드 - #24
Merged
Merged
Conversation
정적 import는 index.js -> parser.js -> parsers/opencode.js 체인에서 프로세스 시동 시 무조건 평가된다. better-sqlite3는 네이티브 모듈이라 ABI 불일치나 빌드 부재로 로드 자체가 실패할 수 있는데, 그 경우 queryOpencodeRows의 try/catch에 도달하기 전에 프로세스가 죽는다. OpenCode를 쓰지 않는 사용자도 tokenphage --help조차 실행되지 않는다. 격리 대상인 try 블록 안에서 동적으로 불러오도록 옮겼다. parseOpencodeDatabase가 이미 await로 호출하므로 시그니처 변경은 없다. 검증: 네이티브 바인딩 파일을 제거한 상태에서 - tokenphage --help -> 정상 종료(rc=0) - parseOpencodeDatabase() -> 예외 없이 빈 배열
11.10.0은 prebuild가 Node 18/20/22/23(ABI 108/115/127/131)까지만 있어 현재 LTS인 Node 24와 최신인 26에서는 소스 컴파일로 넘어간다. 빌드 툴체인이 없는 사용자는 npm install -g 자체가 실패한다. CI에서도 이미 재현되고 있었다 - npm ci가 Node 20/22는 1초, Node 24는 1분. 또 11.x는 node-addon-api를 쓰지 않아 ABI가 고정된다. scheduler가 실행 시점에 최신 node를 동적으로 찾는 설계라(resolve_node), 사용자가 node를 올리면 설치 당시 ABI로 굳은 바이너리를 물어와 매일 조용히 실패한다. 13.0.3은 Node-API(NAPI_VERSION=10) 기반이라 ABI에 무관하고, prebuild 8종(darwin/linux/linuxmusl/win32 x x64/arm64)을 패키지에 동봉해 install 스크립트도 네트워크 왕복도 없다. - engines: Node-API v10 하한(22.14.0+, 23.6.0+)에 맞춰 조정 - CI matrix: engines와 일치시켜 20 제거, 26 추가 - 의존성 37개 제거(prebuild-install 체인), node-addon-api 1개 추가 - npm install 소요 1분 -> 4초
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.
🏷️ 작업 유형
📋 변경 사항
#22 후속. OpenCode SQLite 조회 도입 시 함께 들어온 네이티브 의존성 리스크 2건을 정리한다.
1. 로드 실패 격리 (
src/parsers/opencode.js)import Database from 'better-sqlite3'가 정적 import라index.js→parser.js→parsers/opencode.js체인에서 시동 시 무조건 평가된다. 네이티브 모듈이라 ABI 불일치·빌드 부재로 로드가 실패할 수 있고, 그 경우queryOpencodeRows의 try/catch에 도달하기 전에 프로세스가 죽는다. OpenCode를 쓰지 않는 사용자도tokenphage --help조차 실행되지 않는다.격리 대상인 try 블록 안에서 동적으로 불러오도록 옮겼다.
parseOpencodeDatabase가 이미await로 호출하므로 시그니처 변경은 없다.2. better-sqlite3 11.10.0 → 13.0.3 (
package.json,package-lock.json)NAPI_VERSION=10)prebuild-install || node-gyp rebuildnpm install소요npm install -g자체가 실패한다. CI에서도 이미 재현되고 있었다 —npm ci가 Node 20/22는 1초, Node 24는 1분.scheduler.js의resolve_node()가 실행 시점에 최신 node를 동적으로 찾는 설계라, 사용자가 node를 올리면 설치 당시 ABI로 굳은 바이너리를 물어와 매일 조용히 실패한다.prebuild-install체인),node-addon-api1개 추가.3. 지원 Node 범위 정리 (
package.json,.github/workflows/ci.yml)engines:^20.17.0 || ^22.13.0 || >=23.5.0→^22.14.0 || >=23.6.0['20','22','24']→['22','24','26'](engines와 일치)✅ 테스트
npm test— 185/185 통과, 실패 0npm run test:coverage—opencode.js라인 100% / 분기 92.6%, 전체 95.67% (게이트 80%)node_modules/better-sqlite3/prebuilds/darwin-arm64.node제거 후tokenphage --help→ 정상 종료 (rc=0)parseOpencodeDatabase()→ 예외 없이 빈 배열