fix(lua.core): responses are cut off when they do not fit the socket send buffer

オープン 初心者向け
#243 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
lua
領域
networking

調査の方向性

バグは src/lua/core/server.lua 内の send_raw にあり、単一の非ブロッキングな send() で HTTP レスポンスを送信している。その関数を読み、提案された settimeout 修正を適用するか、部分的な送信を処理せよ。Done は、大きな game-state 応答が早期の接続クローズなしに完全に配信されることを意味する。

索引モデルが issue の本文から書いたものです。

説明

Description

send_raw in src/lua/core/server.lua writes the HTTP response with a single send() on the client socket, which the server put into non-blocking mode (client:settimeout(0)), and then the connection is closed.

LuaSocket's send on a non-blocking socket writes only what fits into the kernel send buffer and returns nil, "timeout", last_byte_sent for the rest. That partial result is not handled, so a large reply (a full game state) is truncated and the client sees the connection close early.

Steps to Reproduce

  1. Run several BalatroBot instances in parallel on a loaded machine
  2. Drive normal runs that return large game states (play, gamestate in the shop).
  3. Occasionally the client gets http.client.RemoteDisconnected: Remote end closed connection without response

It seems to be load-dependent: the slower the client reads, the more likely the reply does not fit the buffer.

Expected Behavior

The whole response is delivered, however large.

Actual Behavior

The response is cut off at whatever fit into the send buffer; the rest is dropped.

Suggested Fix

Smallest change (what we run, as a patch in our container image; we have not seen a cut-off reply
in about 50 container runs since):

BB_SERVER.client_socket:settimeout(5)
local _, err = BB_SERVER.client_socket:send(response_str)

This blocks the game loop for at most 5 s if the client stops reading. If that is not acceptable, the
alternative is to keep the unsent tail (send(data, last + 1)) and finish it on the next update ticks
before closing the socket.

Environment

  • BalatroBot 1.5.2 (and dev at 2026-07-28), Balatro 1.0.1o, Steamodded 1.0.0~BETA-1814a
  • Linux container (Fedora 42, LÖVE 11.5), Python client with urllib

Files

  • src/lua/core/server.lua (send_raw)
主要言語
Python
スター
79
フォーク
23
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

coder/balatrobot のほかの issue

coder/balatrobot の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。