Skip to content

fix(lua.core): prevent concurrent request in lua server #193

@jerem-ai

Description

@jerem-ai

During an automated run (balatrobot v1.5.1, Balatro v1.0.1n, Windows, serve --headless --fast), a pack JSON-RPC call arriving while the pack area was empty/closing crashed the whole game process:

[SMODS balatrobot "src/lua/endpoints/pack.lua"]:127: attempt to index field 'cards' (a nil value)

Repro (from our logs): open a booster pack, then issue pack with a card index after the pack area has emptied (race under high gamespeed — our client polled state, the pack closed between the read and the call). Expected: a typed INVALID_STATE/BAD_REQUEST error response. Actual: unhandled Lua error → 'Oops! The game crashed' → process exit, taking the JSON-RPC server with it.

Suggested fix: guard the pack-area access in pack.lua (~line 127) and return INVALID_STATE when the area is nil/empty.

Context: we run thousands of automated runs against the API (great framework, thank you!) — we've worked around it client-side by never sending pack when our last-seen pack area is empty, but the unguarded path can still be hit by any client racing the animation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions