@microsoft/fetch-event-source
A fetch()-powered client for Server-Sent Events that supports headers, request bodies, and retries
Repository Health
Technical Analysis
@microsoft/fetch-event-source replaces the browser’s built-in EventSource with an implementation built on fetch(), removing that API’s restriction to GET requests with no custom headers or body. It streams and parses Server-Sent Events (SSE) the same way EventSource does, but lets callers set arbitrary headers (for auth tokens), send a POST body, control retry/backoff behavior, and cleanly cancel an in-flight stream via AbortController.
What You Get
- An
fetchEventSource()function with the same event callbacks as nativeEventSource(onopen,onmessage,onclose,onerror) plus full control over method, headers, and body - Automatic reconnect-with-backoff on connection drops, matching the SSE spec’s retry semantics, with a hook to override or disable it
- First-class
AbortController/signalsupport so a caller can cancel a stream cleanly instead of leaking an open connection - A standards-compliant SSE parser (
parse.ts) that handles multi-line data fields, comments, and theretry:/id:control fields per spec
Common Use Cases
- Streaming token-by-token completions from an LLM API (OpenAI, Azure OpenAI) that requires a POST body and bearer-token header
- Building a live-updating dashboard or notification feed that needs SSE but must attach an auth header the native EventSource can’t send
- Replacing polling with a long-lived streamed connection for progress updates on a long-running server-side job
- Any browser client that needs SSE semantics with the flexibility of
fetch()— custom retry logic, request cancellation, or non-GET methods
Under The Hood
Architecture The library is deliberately small: fetch.ts (154 lines) wraps the browser’s native fetch() call, wires it to an AbortController, and manages the retry/backoff loop and event-callback dispatch, while parse.ts (183 lines) implements a dedicated line-based SSE parser that incrementally consumes the streamed response body and emits parsed {event, data, id, retry} messages. index.ts simply re-exports the public fetchEventSource function. Tech Stack Pure TypeScript with zero runtime dependencies, compiled to both CJS (lib/cjs) and ESM (lib/esm) output via two separate tsconfig targets, keeping the published bundle framework-agnostic and usable in any environment with a fetch and ReadableStream implementation. Code Quality The parser has a dedicated Jasmine spec file (parse.spec.ts, 353 lines) exercising SSE parsing edge cases (multi-line fields, comments, partial chunks) in detail, though the higher-level fetch.ts reconnect/backoff logic itself has no equivalent test coverage — test depth is concentrated on the parsing layer, the part most prone to subtle spec-compliance bugs. API Design The API is intentionally a drop-in shape match for the native EventSource callbacks (onopen/onmessage/onerror/onclose), so migrating existing SSE consumer code mostly means swapping the import and adding a fetch-style options object (method, headers, body, signal) — there’s no new mental model to learn, just an extended options surface.
Used by 9 apps in this directory
APITable
Low Code Platforms · Databases
API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.
AnythingLLM
Developer Tools · Automation · AI Assistants
The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.
Flowise
Developer Tools · Automation · No Code Platforms
Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.
Flowsint
Automation · Developer Tools
A privacy-first, graph-based OSINT investigation platform with 30+ automated enrichers for mapping relationships between domains, IPs, people, and organizations.
Markdrop
Note Taking
Visual drag-and-drop markdown editor with GitHub-specific blocks, cloud sync, and offline PWA support
PostHog
Analytics · Monitoring · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
Rivet
AI Agents · Developer Tools
Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.
Skyvern
AI Agents · Automation
Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.
ToolJet
Low Code Platforms · No Code Platforms · AI Agents
Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.