You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(rsocket-core): Pass fragmentation config to server-side responder streams #306
RSocketServer accepts a fragmentation.maxOutboundFragmentSize config, but it only applies to
the requester side (server-initiated requests). The responder side (server responses to client
requests) always uses fragmentSize=0, meaning responses are never fragmented.
This causes a crash when the server tries to send a response larger than 16MB (the RSocket frame
length field is 24-bit, max 16,777,215 bytes), because writeUInt24BE overflows:
RangeError: The value of "value" is out of range. It must be >= 0 and <= 255.
at writeUInt24BE (rsocket-core/src/Codecs.ts:80)
at serializeFrameWithLength (rsocket-core/src/Codecs.ts:161)
Root Cause
Two issues in packages/rsocket-core/src/RSocketServer.ts:
Constructor doesn't store fragmentation: The fragmentation field from ServerConfig is
never assigned to this, so this.fragmentation is always undefined.
DefaultStreamRequestHandler hardcodes fragmentSize=0: Even if this.fragmentation were
stored, the stream handler is created with fragmentSize=0 instead of using the configured value.
-const streamsHandler = new DefaultStreamRequestHandler(responder, 0);+const streamsHandler = new DefaultStreamRequestHandler(+ responder,+ this.fragmentation?.maxOutboundFragmentSize ?? 0,+);
Impact
Without this fix, any RSocket server using rsocket-core v1 cannot send responses larger than ~16MB.
The fragmentation infrastructure (Fragmenter.ts, RequestResponseResponderStream.onNext) already
exists and works correctly — it just never receives a non-zero fragmentSize.
Reproduction
constserver=newRSocketServer({transport: newTcpServerTransport({listenOptions: {port: 9090}}),fragmentation: {maxOutboundFragmentSize: (1<<24)-1-9},// This is ignored!acceptor: {asyncaccept(){return{requestResponse(payload,responder){// This crashes if payload response > 16MBresponder.onNext({data: Buffer.alloc(20_000_000)},true);return{cancel(){},onExtension(){}};},};},},});
Activity
fix(rsocket-core): Pass fragmentation config to server-side responder…
fix(rsocket-core): Pass fragmentation config to server-side responder…