Add one shared encoder for the server's event stream lines
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
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 outConnection. HTTP/2 doesn't allow it, and the runtimes handle it themselves.encodeSSEmust never produce a raw line break inside the data line.JSON.stringifyalready escapes\nand\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
packages/core/src/protocol/v1.ts- The SSE format on MDN
Acceptance criteria
- New
packages/core/src/protocol/sse.ts, exported frompackages/core/src/protocol/index.tsand 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:coverageandpnpm lintpass
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 13
- Forks
- 7
- Ø Merge
- 3 Std. 41 Min.
- Gemergte PRs (30 T.)
- 155
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus codercops/chatcops
-
Document the pre-chat formEvtl. vergeben @masyarakatai hat das vor 5 Tagen übernommen. Offendocumentation good first issue hacktoberfest widget
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
codercops/chatcops#70 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
docs: update the providers page for openai-compatible, registerProvider and provider importsEvtl. vergeben @prakashNalla hat das heute übernommen. Offendocumentation good first issue hacktoberfest website
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 76/100
codercops/chatcops#291 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
docs: add a protocol reference page for custom clientsEvtl. vergeben @kachamsiddarth hat das vor 1 Tag übernommen. Offendocumentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)Evtl. vergeben @bhushan4work hat das heute übernommen. Offenenhancement hacktoberfest help wanted server
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
codercops/chatcops#249 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Create @chatcops/store-sqlite, a store for single-server setupsEvtl. vergeben @srikar-naidu hat das vor 1 Tag übernommen. Offenenhancement hacktoberfest help wanted server
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
codercops/chatcops#247 · 3 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in codercops/chatcops
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
Renaming a projectOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
equinor/prisma-decision-web#927 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
bigbluebutton/bigbluebutton#26166 ·
Maintainer antworten meist innerhalb von 1 Tag