diff --git a/dist/NodeHttpServer.js b/dist/NodeHttpServer.js index ab7c9354853032fefa192ebfa8ab2026bac6ddb7..319815f01e78f5d4e6f7e62a00046ec092eaf797 100644 --- a/dist/NodeHttpServer.js +++ b/dist/NodeHttpServer.js @@ -83,7 +83,17 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* (evaluate, options) }); const address = server.address(); const wss = yield* Effect.acquireRelease(Effect.sync(() => new NodeWS.WebSocketServer({ - noServer: true + noServer: true, + // Patch: upstreamed as https://github.com/Effect-TS/effect/pull/6691 (ships + // in >= 4.0.0-beta.103 as the layer option `websocket: { perMessageDeflate }`). + // On upgrade: drop this patch and pass the option in apps/server/src/server.ts. + // Negotiate permessage-deflate with clients that offer it; clients that + // don't still get uncompressed frames on their connection. Context + // takeover stays enabled (ws default) so the compression window is shared + // across frames — that also makes small frames cheap to compress, so no + // size threshold is set (ws only honors `threshold` when context takeover + // is disabled). + perMessageDeflate: true })), wss => Effect.callback(resume => { wss.close(() => resume(Effect.void)); })).pipe(Scope.provide(scope), Effect.cached); diff --git a/src/NodeHttpServer.ts b/src/NodeHttpServer.ts index e18cd931f17c26d6ca985a2d1ece9e9d760851d3..9c888a581738aea12dbdb2b213cce1c480aa2ecc 100644 --- a/src/NodeHttpServer.ts +++ b/src/NodeHttpServer.ts @@ -116,7 +116,21 @@ export const make = Effect.fnUntraced(function*( const address = server.address()! const wss = yield* Effect.acquireRelease( - Effect.sync(() => new NodeWS.WebSocketServer({ noServer: true })), + Effect.sync(() => + new NodeWS.WebSocketServer({ + noServer: true, + // Patch: upstreamed as https://github.com/Effect-TS/effect/pull/6691 (ships + // in >= 4.0.0-beta.103 as the layer option `websocket: { perMessageDeflate }`). + // On upgrade: drop this patch and pass the option in apps/server/src/server.ts. + // Negotiate permessage-deflate with clients that offer it; clients that + // don't still get uncompressed frames on their connection. Context + // takeover stays enabled (ws default) so the compression window is + // shared across frames — that also makes small frames cheap to + // compress, so no size threshold is set (ws only honors `threshold` + // when context takeover is disabled). + perMessageDeflate: true + }) + ), (wss) => Effect.callback((resume) => { wss.close(() => resume(Effect.void))