Add max rsocket payload size
Summary: We're seeing some crashes when attempting to send payloads larger than are supported by rsocket. Instead of crashing, skip the message, but log it so we can see what it's containing. This is where the failure occurs: https://github.com/rsocket/rsocket-cpp/blob/master/rsocket/framing/FramedDuplexConnection.cpp#L64 Reviewed By: passy Differential Revision: D12857616 fbshipit-source-id: 2b02d7f5dd6499ba81783d3f8aefcbb64d9d408a
This commit is contained in:
committed by
Facebook Github Bot
parent
b3f9bd9ee1
commit
db833d36e9
@@ -29,6 +29,8 @@ static constexpr int connectionKeepaliveSeconds = 10;
|
||||
static constexpr int securePort = 8088;
|
||||
static constexpr int insecurePort = 8089;
|
||||
|
||||
static constexpr int maxPayloadSize = 0xFFFFFF;
|
||||
|
||||
namespace facebook {
|
||||
namespace flipper {
|
||||
|
||||
@@ -216,9 +218,22 @@ void FlipperConnectionManagerImpl::setCallbacks(Callbacks* callbacks) {
|
||||
|
||||
void FlipperConnectionManagerImpl::sendMessage(const folly::dynamic& message) {
|
||||
flipperEventBase_->add([this, message]() {
|
||||
std::string json = folly::toJson(message);
|
||||
rsocket::Payload payload = rsocket::Payload(json);
|
||||
auto payloadLength = payload.data->computeChainDataLength();
|
||||
|
||||
DCHECK_LE(payloadLength, maxPayloadSize);
|
||||
if (payloadLength > maxPayloadSize) {
|
||||
auto logMessage =
|
||||
std::string(
|
||||
"Error: Skipping sending message larger than max rsocket payload: ") +
|
||||
json;
|
||||
log(logMessage);
|
||||
return;
|
||||
}
|
||||
if (client_) {
|
||||
client_->getRequester()
|
||||
->fireAndForget(rsocket::Payload(folly::toJson(message)))
|
||||
->fireAndForget(std::move(payload))
|
||||
->subscribe([]() {});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user