Skip to content

post(blog): TypeScript 비동기 제너레이터 포스트 추가 (#107) - #136

Merged
Malloc72P merged 2 commits into
mainfrom
claude/issue-107-async-generator
Jul 16, 2026
Merged

post(blog): TypeScript 비동기 제너레이터 포스트 추가 (#107)#136
Malloc72P merged 2 commits into
mainfrom
claude/issue-107-async-generator

Conversation

@Malloc72P

Copy link
Copy Markdown
Owner

개요

Closes #107

이슈 #107(Typescript와 비동기 제너레이터 함수)을 다루는 새 포스트를 추가합니다.

  • 경로: apps/blog/src/app/(main)/posts/frontend/async-generator/page.mdx
  • 제목: 여러 번 리턴하는 함수: TypeScript 비동기 제너레이터로 SSE 소비와 메인 스레드 양보까지

구성

  • 비동기 제너레이터 기초: function*async function* 단계적 도입, yield/next()/for await...of, 비동기 이터레이션 프로토콜(Symbol.asyncIterator), AsyncGenerator<T, TReturn, TNext> 타입
  • SSE 스트림 소비: fetch ReadableStream의 청크 파싱을 제너레이터로 분리해 소비자 코드를 단순화 (기존 /posts/ai/sse-exam 포스트와 내부 링크로 연계)
  • 무거운 계산 + 이벤트 루프 양보: 렌더링이 태스크 사이에서만 일어나는 이유, await Promise.resolve()(마이크로태스크)로는 양보가 안 되는 함정, setTimeout(0) 태스크 경계 양보 + 청크 처리 패턴 (기존 /posts/frontend/event-loop 포스트와 연계)
  • 마무리: 웹 워커 vs 비동기 제너레이터 양보 비교와 선택 기준

검증

  • 본문 코드 예제 전부 Node 22에서 실행 검증 (제너레이터 기초/프로토콜/TNext, 로컬 SSE 서버 대상 readSSE 청크 분할·멀티바이트 포함, processInChunks 결과 일치 및 매크로태스크 양보 여부 실측 — 마이크로태스크만으로는 양보되지 않음 확인)
  • pnpm run build 통과 (async-generator 라우트 생성 확인)
  • pnpm run lint (--max-warnings 0) 통과
  • apps/blog pnpm test 통과 (26 suites / 115 tests)
  • dev 서버에서 페이지 렌더링 확인 (강조 문법 깨짐 0건, 헤딩 구조 H1 1개 + H2/H3, 내부 링크 정상)

- function* → async function* → for await...of 메커니즘과 AsyncGenerator 타입 정리
- SSE 스트림 파싱을 비동기 제너레이터로 분리하는 예시 (sse-exam 포스트 연계)
- 태스크 경계 양보로 렌더링 블로킹 없는 무거운 계산 처리와 웹 워커 비교
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
blog Ignored Ignored Preview Jul 16, 2026 7:31am

- readSSE에 try/finally 연결 정리 추가, 스펙 단순화 명시, 원본 대비 개선점·콜백 대안 비교 서술 보강
- 렌더링 타이밍 규칙의 출처 정정(이벤트 루프 포스트 아님), pending/이행된 Promise await 구분 추가, scheduler.yield 지원 현황 구체화
- chunkSize 기본값 1,000→200(실측 50ms로 16ms 예산 초과), H1→H2 헤딩 통일, 조사·비문 등 문장 손질
@Malloc72P
Malloc72P merged commit 9e63144 into main Jul 16, 2026
3 checks passed
@Malloc72P
Malloc72P deleted the claude/issue-107-async-generator branch July 16, 2026 07:33
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.

Typescript와 비동기 제너레이터 함수(async generator)

1 participant