Skip to content

Commit

Permalink
use constant kj::WebSocket::SUGGESTED_MAX_MESSAGE_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
RamIdeas committed Aug 2, 2024
1 parent e1fcf20 commit bfbfda1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/workerd/api/web-socket.c++
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ WebSocket::Accepted::~Accepted() noexcept(false) {
}

void WebSocket::startReadLoop(jsg::Lock& js, kj::Maybe<kj::Own<InputGate::CriticalSection>> cs) {
size_t maxMessageSize = 1u << 20;
size_t maxMessageSize = kj::WebSocket::SUGGESTED_MAX_MESSAGE_SIZE;
if (FeatureFlags::get(js).getIncreaseWebsocketMessageSize()) {
maxMessageSize = 128u << 20;
}
Expand Down
5 changes: 4 additions & 1 deletion src/workerd/api/web-socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ class WebSocket: public EventTarget {
// `close()`, thereby preventing calls to `send()` even after we wake from hibernation.
bool closedOutgoingForHib = false;

// Maximum allowed size for WebSocket messages
inline static const size_t SUGGESTED_MAX_MESSAGE_SIZE = 1u << 20;

// Maximum size of a WebSocket attachment.
inline static const size_t MAX_ATTACHMENT_SIZE = 1024 * 2;

Expand Down Expand Up @@ -648,7 +651,7 @@ class WebSocket: public EventTarget {
IoContext& context, OutgoingMessagesMap& outgoingMessages, kj::WebSocket& ws, Native& native,
AutoResponse& autoResponse, kj::Maybe<kj::Own<WebSocketObserver>>& observer);

kj::Promise<kj::Maybe<kj::Exception>> readLoop(kj::Maybe<kj::Own<InputGate::CriticalSection>> cs);
kj::Promise<kj::Maybe<kj::Exception>> readLoop(kj::Maybe<kj::Own<InputGate::CriticalSection>> cs, size_t maxMessageSize);

void reportError(jsg::Lock& js, kj::Exception&& e);
void reportError(jsg::Lock& js, jsg::JsRef<jsg::JsValue> err);
Expand Down

0 comments on commit bfbfda1

Please # to comment.