Skip to content

refactor: remove dead code and align with effect best practices#150

Merged
Palbahngmiyine merged 1 commit intosolapi:betafrom
Palbahngmiyine:sync/refactor-to-beta
Apr 16, 2026
Merged

refactor: remove dead code and align with effect best practices#150
Palbahngmiyine merged 1 commit intosolapi:betafrom
Palbahngmiyine:sync/refactor-to-beta

Conversation

@Palbahngmiyine
Copy link
Copy Markdown
Member

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

  • Dead code: src/lib/effectErrorHandler.ts의 production 미사용 runSafeSync 제거 + 테스트를 runSafePromise로 이관
  • Path aliases: src/ 내 4개 파일의 @/ 혼용을 @errors/@models로 통일, tsconfig.json@errors/* 매핑 추가 (tsup.config.ts/CLAUDE.md와 정합)
  • Clarity: src/lib/defaultFetcher.ts의 inline 재시도 감지 로직을 isRetryableNetworkError 헬퍼 + RETRYABLE_ERROR_KEYWORDS / ERROR_MESSAGE_PREVIEW_LENGTH 상수로 분리
  • Effect best practice: src/lib/schemaUtils.tsdecodeWithBadRequest가 Effect 공식 ParseResult.TreeFormatter + ArrayFormatter를 사용해 구조화된 validationErrors(경로 포함)를 BadRequestError에 주입
  • Style: commonTypes.ts, models/index.ts, naverOption.ts, getMessagesRequest.ts의 WHAT/섹션 분할 주석 제거
  • Docs: CLAUDE.md, AGENTS.md에서 runSafeSync 언급 제거

Verification (upstream/beta 기반)

  • pnpm lint — Biome clean
  • pnpm test — 277/277 passed
  • pnpm 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

  • upstream CI 통과 확인
  • Public API 시그니처 무변경 확인 (runSafeSync는 src/index.ts에서 re-export되지 않은 internal 심볼)

🤖 Generated with Claude Code

- 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>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/lib/defaultFetcher.ts
Comment on lines +32 to +40
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));
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

isRetryableNetworkError 함수에서 error.causeError 인스턴스인 경우, 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));
};

@Palbahngmiyine Palbahngmiyine merged commit 8451c14 into solapi:beta Apr 16, 2026
6 checks passed
@Palbahngmiyine Palbahngmiyine deleted the sync/refactor-to-beta branch April 16, 2026 23:50
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