개요
Effect는 견고하고 유지보수가 쉬우며 타입 안전한 프로덕션급 TypeScript 애플리케이션을 구축하기 위한 라이브러리입니다. 타입화된 오류 처리, 의존성 주입, 구조적 동시성, 스케줄링, 분산 트레이싱, 통합된 데이터 스키마 유효성 검사를 제공합니다. 이 monorepo에는 Node.js, Bun, Deno 및 브라우저용 플랫폼 패키지와 다양한 SQL 및 AI 통합도 포함되어 있습니다.
README 미리보기
\n\n[](https://pkg.pr.new/~/Effect-TS/effect)\n\n# Effect\n\nEffect is a library for building robust, maintainable, type-safe, and production grade applications in TypeScript. It helps you handle the hard problems at scale: typed errors, dependency injection, structured concurrency, scheduling, tracing, and unified schema validation.\n\n> **Effect 4.x is a long-term support (LTS) release.** If you are upgrading from Effect 3.x, follow the [migration guide](MIGRATION.md).\n\n## Installation\n\n```sh\nnpm install effect\n```\n\n## Requirements\n\n- **TypeScript 5.9 or newer.** TypeScript 7 is recommended for the best performance and compatibility with [Effect's TypeScript tooling](https://github.com/Effect-TS/tsgo#installation).\n- **Node.js 18 or newer** is the general minimum for running Effect on Node.js. Some integration packages require newer runtimes; for example, `@effect/sql-sqlite-node` requires Node.js 22.16 or newer.\n- **Strict type-checking:** the `strict` flag must be enabled in your `tsconfig.json`.\n\n## Links\n\n- [Website](https://effect.website): documentation, guides, and news\n- [Discord](https://discord.gg/effect-ts): ask questions, share what you're building, and talk to the core team\n- [Community](https://effect.website/community-hub): meetups and events, or bring Effect to your own\n- [Issues](https://github.com/Effect-TS/effect/issues): bug reports and feature requests\n- [Jobs](https://effect.website/effect-jobs): companies hiring Effect developers\n- Follow us on [X](https://x.com/EffectTS_), [Bluesky](https://bsky.app/profile/effect-ts.bsky.social), and [LinkedIn](https://www.linkedin.com/company/effect-ts)\n\n## Let's talk\n\nWhether your team is considering Effect, rolling it out, or already running it in production, we'd love to hear from you: what you're building, what works, and what you need from Effect next.\n\n- **Talk to the maintainers.** Introduce your team on [Discord](https://discord.gg/effect-ts) or email [contact@effectful.
FAQ (2)
문제 해결staleWhileRevalidate 새로 고침이 실패한 후에도 Effect의 RequestResolver.persisted가 갱신된 TTL로 오래된 데이터를 계속 제공하는 이유는 무엇인가요?
이는 Effect 4.0.5의 버그입니다 (main에도 여전히 존재합니다). staleWhileRevalidate를 사용할 때, 백그라운드 새로고침의 runAll이 배치 전체로 실패하거나 (또는 엔트리를 완료하지 않은 채 성공하면), persisted가 실패를 저장하는 대신 이전에 저장된 값을 새로운 TTL과 함께 다시 기록합니다. 그 결과 오래된(stale) 엔트리가 부활하여 무기한 연장됩니다. 엔트리 단위의 실패는 올바르게 저장됩니다. 우회 방법: 이펙트 전체를 실패시키는 대신 resolver가 각 요청을 개별적으로 완료하도록 만드세요. resolver 내부에서 오류를 잡아 모든 엔트리를 직접 실패시키면 됩니다:
const resolver = RequestResolver.make<GetValue>((entries) =>
Effect.catchAll(backendCall(entries), (err) =>
Effect.sync(() => {
for (const entry of entries) entry.completeUnsafe(Exit.fail(err))
})
)
)
엔트리 단위로 완료하면 실패가 PersistenceStore.setMany를 통해 저장되고 오래된 값이 다시 기록되지 않습니다. 업스트림 수정 사항은 effect-ts issue #9583에서 추적하세요.
문제 해결Effect에서 FiberMap.run / FiberHandle.run이 스코프가 닫힐 때 대체된 파이버의 cleanup을 기다리지 않는 이유는 무엇인가요?
effect@4.0.5에서 점유된 키/핸들에 대해 FiberMap.run(또는 FiberHandle.run, set, runtime)을 호출하면, 이전 파이버를 대기하지 않은 채 인터럽트하고 컨테이너에서 분리합니다. 스코프의 finalizer는 컨테이너에 남아 있는 파이버만 대기하므로, 교체된 파이버의 인터럽션 정리 작업(예: Effect.onInterrupt)이 아직 실행 중인 동안 스코프가 닫히면서 리소스가 해제됩니다. NodeRuntime.runMain 환경에서는 SIGTERM 이후 해당 정리 작업이 완료되기 전에 프로세스가 종료될 수도 있습니다.
해결 방법: remove/clear는 인터럽션이 완료될 때까지 대기하므로, 교체하기 전에 이전 파이버를 명시적으로 제거하고 대기하세요:
// FiberMap: 먼저 remove한 후 run
yield* FiberMap.remove(map, "k")
yield* FiberMap.run(map, "k", newEffect)
// FiberHandle: 먼저 clear한 후 run
yield* FiberHandle.clear(handle)
yield* FiberHandle.run(handle, newEffect)
이렇게 하면 교체가 시작되기 전과 스코프가 닫히기 전에 이전 파이버의 정리 작업이 완료되는 것이 보장되어, 예상되는 해제 순서(정리 작업이 외부 리소스 해제보다 먼저 실행됨)가 복원됩니다.