Skip to content

Commit

Permalink
fix: Limit ws payload size
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Aug 16, 2022
1 parent cfa7ecd commit ed8176c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/scenes/Document/components/MultiplayerEditor.tsx
Expand Up @@ -139,6 +139,9 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) {
});

if (debug) {
provider.on("close", (ev: MessageEvent) =>
Logger.debug("collaboration", "close", ev)
);
provider.on("message", (ev: MessageEvent) =>
Logger.debug("collaboration", "incoming", {
message: ev.message,
Expand Down
2 changes: 2 additions & 0 deletions server/services/collaboration.ts
Expand Up @@ -4,6 +4,7 @@ import url from "url";
import { Server } from "@hocuspocus/server";
import Koa from "koa";
import WebSocket from "ws";
import { DocumentValidation } from "@shared/validations";
import Logger from "@server/logging/Logger";
import AuthenticationExtension from "../collaboration/AuthenticationExtension";
import LoggerExtension from "../collaboration/LoggerExtension";
Expand All @@ -18,6 +19,7 @@ export default function init(
const path = "/collaboration";
const wss = new WebSocket.Server({
noServer: true,
maxPayload: DocumentValidation.maxStateLength,
});

const hocuspocus = Server.configure({
Expand Down
2 changes: 1 addition & 1 deletion shared/validations.ts
Expand Up @@ -32,7 +32,7 @@ export const DocumentValidation = {
maxTitleLength: 100,

/** The maximum size of the collaborative document state */
maxStateLength: 1000000,
maxStateLength: 1500 * 1024,
};

export const PinValidation = {
Expand Down

0 comments on commit ed8176c

Please sign in to comment.