Debugging a mysterious HTTP streaming issue
19 days ago
- #Debugging
- #Cloudflare
- #HTTP Streaming
- Encountered HTTP response streaming issues with AI SDK and Node stream API
- Streaming worked with cURL and Postman but failed with node-fetch and browser fetch
- Initial hypothesis was HTTP/2 compliance issues with web streams vs Node streams
- Discovered a temporary fix using a Cloudflare worker as middleware
- Ruled out HTTP version differences as the root cause
- Suspected header stripping ('Transfer-Encoding', 'Connection', 'Content-Encoding') as the issue
- Learned about dynamic responses and HTTP streaming mechanics
- Breakthrough came from noticing cURL's lack of 'Accept-Encoding' header by default
- Identified compression as the root cause and disabled it in Cloudflare
- Realized this was a recurring issue previously encountered at Trieve
- Highlighted Cloudflare's unpredictable behavior with silent configuration changes
- Lessons: compression breaks streaming, cURL vs fetch differences, Cloudflare workers as debugging tools, importance of source availability, and team knowledge sharing