diff --git a/plugins/http_plugin/include/eosio/http_plugin/common.hpp b/plugins/http_plugin/include/eosio/http_plugin/common.hpp index 090464f068..100bee41f8 100644 --- a/plugins/http_plugin/include/eosio/http_plugin/common.hpp +++ b/plugins/http_plugin/include/eosio/http_plugin/common.hpp @@ -156,16 +156,16 @@ inline auto make_http_response_handler(http_plugin_state& plugin_state, detail:: return [&plugin_state, session_ptr{std::move(session_ptr)}, content_type](int code, std::optional response) mutable { auto payload_size = detail::in_flight_sizeof(response); - if(auto error_str = session_ptr->verify_max_bytes_in_flight(payload_size); !error_str.empty()) { - session_ptr->send_busy_response(std::move(error_str)); - return; - } - plugin_state.bytes_in_flight += payload_size; // post back to an HTTP thread to allow the response handler to be called from any thread boost::asio::dispatch(plugin_state.thread_pool.get_executor(), [&plugin_state, session_ptr{std::move(session_ptr)}, code, payload_size, response = std::move(response), content_type]() { + if(auto error_str = session_ptr->verify_max_bytes_in_flight(0); !error_str.empty()) { + session_ptr->send_busy_response(std::move(error_str)); + return; + } + try { plugin_state.bytes_in_flight -= payload_size; if (response.has_value()) {