refactor: remove dead code and align with effect best practices#150
Conversation
- Remove unused runSafeSync from effectErrorHandler (dead code) - Unify path aliases to domain-specific form (@/ -> @errors, @models) - Add @errors/* path to tsconfig to match documented alias scheme - Extract retryable error detection helper in defaultFetcher - Adopt ParseResult TreeFormatter/ArrayFormatter in decodeWithBadRequest - Remove redundant WHAT/section comments; keep TSDoc and WHY-only Verified with pnpm lint, pnpm test (277/277), pnpm build, and @effect/language-service diagnostics (0 errors / 0 warnings / 88 files). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request removes the runSafeSync utility and its associated tests, while enhancing error handling and reporting. Key improvements include the integration of ParseResult formatters for structured validation errors in decodeWithBadRequest and the extraction of network retry logic in defaultFetcher.ts. The PR also refactors imports to use a new @errors path alias and removes redundant comments. A review comment suggests further improving network error detection by checking the cause.message property.
| const isRetryableNetworkError = (error: Error): boolean => { | ||
| const cause = error.cause; | ||
| const causeCode = | ||
| cause && typeof cause === 'object' && 'code' in cause | ||
| ? String(cause.code) | ||
| : ''; | ||
| const message = `${error.message} ${causeCode}`.toLowerCase(); | ||
| return RETRYABLE_ERROR_KEYWORDS.some(keyword => message.includes(keyword)); | ||
| }; |
There was a problem hiding this comment.
isRetryableNetworkError 함수에서 error.cause가 Error 인스턴스인 경우, code 속성뿐만 아니라 cause.message도 함께 확인하는 것이 더 안전합니다. Node.js의 fetch (undici) 등 일부 환경에서는 실제 네트워크 에러 정보가 cause.message에 담기는 경우가 많기 때문입니다.
const isRetryableNetworkError = (error: Error): boolean => {
const cause = error.cause;
const causeInfo =
cause instanceof Error
? `${cause.message} ${'code' in cause ? String(cause.code) : ''}`
: cause && typeof cause === 'object' && 'code' in cause
? String(cause.code)
: String(cause ?? '');
const message = `${error.message} ${causeInfo}`.toLowerCase();
return RETRYABLE_ERROR_KEYWORDS.some(keyword => message.includes(keyword));
};
Summary
worktree-unified-prancing-moonbeam브랜치에서 진행한 refactor만 beta에 반영합니다. 기존 PR #149는 upstream master/beta 격차로 인한 workflow 파일 충돌이 있어 close하고, upstream/beta 기반으로 refactor 커밋(da2b980)만 cherry-pick했습니다. workflow/CI 관련 파일은 이 PR에서 다루지 않으며, upstream master에 이미 통합된 상태를 유지합니다.15 파일 / +71 -120.
Changes
src/lib/effectErrorHandler.ts의 production 미사용runSafeSync제거 + 테스트를runSafePromise로 이관@/혼용을@errors/@models로 통일,tsconfig.json에@errors/*매핑 추가 (tsup.config.ts/CLAUDE.md와 정합)src/lib/defaultFetcher.ts의 inline 재시도 감지 로직을isRetryableNetworkError헬퍼 +RETRYABLE_ERROR_KEYWORDS/ERROR_MESSAGE_PREVIEW_LENGTH상수로 분리src/lib/schemaUtils.ts의decodeWithBadRequest가 Effect 공식ParseResult.TreeFormatter+ArrayFormatter를 사용해 구조화된validationErrors(경로 포함)를BadRequestError에 주입commonTypes.ts,models/index.ts,naverOption.ts,getMessagesRequest.ts의 WHAT/섹션 분할 주석 제거CLAUDE.md,AGENTS.md에서runSafeSync언급 제거Verification (upstream/beta 기반)
pnpm lint— Biome cleanpnpm test— 277/277 passedpnpm build— tsup + .d.ts 정상npx effect-language-service diagnostics— 0 errors / 0 warnings / 0 messages (88 파일)rg "runSafeSync" src— 0건rg "from '@/" src— 0건Test plan
runSafeSync는 src/index.ts에서 re-export되지 않은 internal 심볼)🤖 Generated with Claude Code