mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Document that streaming responses are already excluded from compression
Clarified in code comments and documentation that: - Streaming responses (ReadableStream bodies) are rejected from StaticRoute - They throw error at StaticRoute.fromJS():160 requiring buffered body - Streams go through RequestContext, not StaticRoute - Compression only applies to fully buffered static Response objects This answers the "how does streaming work" question - it doesn't go through StaticRoute at all, so compression is never applied to streams. No special handling needed - the architecture naturally prevents it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -249,6 +249,9 @@ pub fn onRequest(this: *StaticRoute, req: *uws.Request, resp: AnyResponse) void
|
||||
}
|
||||
|
||||
/// Try to serve a compressed variant if compression is enabled and conditions are met
|
||||
///
|
||||
/// NOTE: Streaming responses are NOT handled here - they're rejected at fromJS() line 160
|
||||
/// and go through RequestContext instead. This only compresses fully buffered static responses.
|
||||
fn tryServeCompressed(this: *StaticRoute, req: *uws.Request, resp: AnyResponse) bool {
|
||||
const server = this.server orelse return false;
|
||||
const config = server.compressionConfig() orelse return false;
|
||||
|
||||
@@ -24,11 +24,11 @@ pub const COMPRESSION_ENABLED_BY_DEFAULT = false;
|
||||
/// - Only caches variants that clients actually request (lazy)
|
||||
/// - Compression often makes files smaller, but we store BOTH original and compressed
|
||||
///
|
||||
/// ## Not Supported (Yet):
|
||||
/// - Dynamic routes (would need LRU cache with TTL and size limits)
|
||||
/// - Streaming responses
|
||||
/// - Cache eviction or memory limits
|
||||
/// - Selective caching per-route
|
||||
/// ## Not Supported:
|
||||
/// - **Dynamic routes** - Responses from fetch() handlers (would need LRU cache with TTL)
|
||||
/// - **Streaming responses** - ReadableStream bodies are rejected from static routes (see StaticRoute.zig:160)
|
||||
/// - **Cache eviction** - No memory limits or LRU eviction
|
||||
/// - **Per-route control** - Can only enable/disable globally or per-algorithm
|
||||
///
|
||||
/// ## Usage:
|
||||
/// ```js
|
||||
|
||||
Reference in New Issue
Block a user