Streaming Output and Terminal Rendering: Hand-Writing an SSE Parser, Incremental Markdown, and an Interruptible Typewriter
Peel back the gateway's SSE byte stream one layer at a time: parse events, merge them into incremental events, then hand them to a renderer that prints character by character — and handle stream disconnects, cursor control, and user keypress interrupts, the three things real engineering gets wrong most often.
Peel back the gateway's SSE byte stream one layer at a time: parse events, merge them into incremental events, then hand them to a renderer that prints character by character — and handle stream disconnects, cursor control, and user keypress interrupts, the three things real engineering gets wrong most often.
Interview questions
What edge cases bite you when hand-writing an SSE parser, and why can't you just read line by line?手写一个 SSE 解析器,有哪些容易踩的边界条件?为什么不能直接按行读?
Common in ChinaCommon overseasBasic#sse#streaming🔒 Unlock this chapter to see the answer keys.
A streaming response dies halfway through. How should the client handle it, and what does retrying actually cost?流式响应在中途断开,客户端该怎么处理?重试的代价是什么?
Common in ChinaCommon overseasDeep dive#streaming#error-handling🔒 Unlock this chapter to see the answer keys.
What makes incremental Markdown rendering in a terminal hard, and how do you trade correctness against responsiveness?在终端里做增量 Markdown 渲染,难点在哪?正确性与实时性冲突时你怎么权衡?
Common in ChinaCommon overseasIntermediate#terminal-ui#streaming🔒 Unlock this chapter to see the answer keys.
