Skip to content

Support Uint8Array / Buffer in api.stream* endpoints #2003

@lilWolf011

Description

@lilWolf011

🚀 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions