Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add one shared encoder for the server's event stream lines

Đang mở
#241 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@kachamsiddarth đang làm issue này rồi.

Từ ngày 20/10/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

core enhancement good first issue hacktoberfest

Each server adapter builds its own SSE lines and writes its own data: [DONE] (packages/server/src/adapters/express.ts, lines 59 and 61, vercel.ts, lines 55 and 57, cloudflare.ts, lines 72 and 74), and their headers differ slightly. For protocol v1, one module will own the format so the adapters only move bytes. This issue is that module.

What to do
Create packages/core/src/protocol/sse.ts:

/** One event: `data: <json>` and a blank line. */
export function encodeSSE(part: WirePart | Record<string, unknown>): string;

/** A comment line that keeps the connection busy while nothing else is sent. */
export const SSE_PING: string;     // ': ping\n\n'

/** Ends the stream. */
export const SSE_DONE: string;     // 'data: [DONE]\n\n'

export const SSE_HEADERS: Readonly<Record<string, string>>;
  • SSE_HEADERS: Content-Type: text/event-stream; charset=utf-8, Cache-Control: no-cache, no-transform (stops proxies from compressing and buffering), X-Accel-Buffering: no (nginx). Leave out Connection. HTTP/2 doesn't allow it, and the runtimes handle it themselves.
  • encodeSSE must never produce a raw line break inside the data line. JSON.stringify already escapes \n and \r, so test that a part with line breaks in its text stays on one line. Also test that U+2028 and U+2029 survive.

Where to look

Acceptance criteria

  • New packages/core/src/protocol/sse.ts, exported from packages/core/src/protocol/index.ts and from @chatcops/core
  • Tests for the line format, line breaks in text, U+2028/U+2029, and the exact header values
  • The adapters aren't changed in this PR (I switch them over in the protocol PR)
  • Changeset for @chatcops/core (minor)
  • pnpm test:coverage and pnpm lint pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #<this issue number>. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.

Ngôn ngữ chính
TypeScript
Star
13
Fork
7
Merge trung bình
4 giờ 11 phút
Pull request đã merge (30 ngày)
122

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codercops/chatcops

Tất cả issue của codercops/chatcops

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.