diff --git a/src/communication/bolt/v1/session.hpp b/src/communication/bolt/v1/session.hpp
index 34673897a..bd9e193e3 100644
--- a/src/communication/bolt/v1/session.hpp
+++ b/src/communication/bolt/v1/session.hpp
@@ -72,6 +72,11 @@ class Session {
    */
   void Execute() {
     if (UNLIKELY(!handshake_done_)) {
+      // Resize the input buffer to ensure that a whole chunk can fit into it.
+      // This can be done only once because the buffer holds its size.
+      input_stream_.Resize(WHOLE_CHUNK_SIZE);
+
+      // Receive the handshake.
       if (input_stream_.size() < HANDSHAKE_SIZE) {
         DLOG(WARNING) << fmt::format("Received partial handshake of size {}",
                                      input_stream_.size());
diff --git a/tests/unit/bolt_common.hpp b/tests/unit/bolt_common.hpp
index 47dd75b3a..099f5fc95 100644
--- a/tests/unit/bolt_common.hpp
+++ b/tests/unit/bolt_common.hpp
@@ -34,6 +34,8 @@ class TestInputStream {
     data_.erase(data_.begin(), data_.begin() + count);
   }
 
+  void Resize(size_t len) {}
+
  private:
   std::vector<uint8_t> data_;
 };