Skip to content

Commit 8301b1b

Browse files
committed
fix: adjust compression / data stream thresholds to not be inclusive
1 parent d575a12 commit 8301b1b

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/room/rpc/RpcClientManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ export default class RpcClientManager {
157157
const payloadBytes = byteLength(payload);
158158

159159
let mode: 'regular' | 'compressed' | 'compressed-data-stream' = 'regular';
160-
if (remoteClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC && payloadBytes >= COMPRESS_MIN_BYTES) {
160+
if (remoteClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC && payloadBytes > COMPRESS_MIN_BYTES) {
161161
mode = 'compressed';
162162
}
163-
if (mode === 'compressed' && payloadBytes >= DATA_STREAM_MIN_BYTES) {
163+
if (mode === 'compressed' && payloadBytes > DATA_STREAM_MIN_BYTES) {
164164
mode = 'compressed-data-stream';
165165
}
166166

src/room/rpc/RpcServerManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export default class RpcServerManager {
163163
// for lower TTFB
164164
if (
165165
callerClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC &&
166-
responseBytes >= DATA_STREAM_MIN_BYTES
166+
responseBytes > DATA_STREAM_MIN_BYTES
167167
) {
168168
const writer = await this.outgoingDataStreamManager.streamBytes({
169169
topic: RPC_DATA_STREAM_TOPIC,
@@ -180,7 +180,7 @@ export default class RpcServerManager {
180180
// Medium response: compress inline
181181
if (
182182
callerClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC &&
183-
responseBytes >= COMPRESS_MIN_BYTES
183+
responseBytes > COMPRESS_MIN_BYTES
184184
) {
185185
const compressed = await gzipCompress(response!);
186186
await this.engine.publishRpcResponseCompressed(callerIdentity, requestId, compressed);
@@ -283,7 +283,7 @@ export default class RpcServerManager {
283283

284284
if (
285285
callerClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC &&
286-
responseBytes >= DATA_STREAM_MIN_BYTES
286+
responseBytes > DATA_STREAM_MIN_BYTES
287287
) {
288288
// Large response: create the data stream tagged with the request ID,
289289
// send the RPC response with empty payload, then stream compressed chunks
@@ -301,7 +301,7 @@ export default class RpcServerManager {
301301

302302
if (
303303
callerClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC &&
304-
responseBytes >= COMPRESS_MIN_BYTES
304+
responseBytes > COMPRESS_MIN_BYTES
305305
) {
306306
// Medium response: compress inline
307307
const compressed = await gzipCompress(response);

0 commit comments

Comments
 (0)