-
Notifications
You must be signed in to change notification settings - Fork 484
Description
🚀 Feature Request: Binary support in streaming APIs
Hi Encore team 👋,
I’m a happy Encore user working with the api.streamInOut
and related streaming functionality. Currently, these APIs only support JSON-compatible types (string
, number
, boolean
, object
), which limits binary use cases.
For example, this is not supported:
interface StreamIn {
data: Uint8Array; // ❌ not currently allowed
}
interface StreamOut {
data: Uint8Array;
}
🧩 Problem
Because Uint8Array
or Buffer
aren't supported, we have to base64-encode binary
payloads to stream data between client and server.
This results in:
📦 ~33% payload overhead due to base64
🧮 Additional CPU usage from base64 encode/decode
🔁 Increased complexity on both ends
✅ Proposed Solution
Support Uint8Array (or Buffer)
directly in streamed API definitions:
interface StreamIn {
data: Uint8Array;
}
interface StreamOut {
data: Uint8Array;
}
This would allow zero-copy, efficient binary streaming using msgpack
, Protobuf
, or similar.
🎯 Benefits
Improved performance: smaller payloads, less CPU work
Cleaner code: no need for manual base64 encoding/decoding
Better developer experience: closer to native WebSocket / streaming behavior
Future-friendly: enables higher throughput real-time use cases
🙏 Summary
Problem: Streaming endpoints only allow JSON-serializable types
Impact: Workarounds required for binary data, leading to inefficiency
Request: Add support for Uint8Array or Buffer in streaming APIs
Would love to see this in the roadmap — I’d be happy to help test or prototype if needed. Thanks for your amazing work on Encore!