fix: preserve active matchmaking on transient errors

This commit is contained in:
Josh Creek
2026-08-31 22:39:42 +01:00
parent 47550aefae
commit 550d73f1d7
2 changed files with 25 additions and 4 deletions
+16 -4
View File
@@ -40,7 +40,10 @@ func queue_create(ticket_id: String, playlist: String, client_build: String, pro
return ERR_INVALID_PARAMETER
if not state.begin_queue(ticket_id, playlist):
return ERR_INVALID_PARAMETER
return _start_request("queue_create", HTTPClient.METHOD_POST, "/v1/queue", {"ticket_id": ticket_id, "playlist": playlist, "client_build": client_build, "protocol_version": protocol_version}, _idempotency_key("queue"))
var err := _start_request("queue_create", HTTPClient.METHOD_POST, "/v1/queue", {"ticket_id": ticket_id, "playlist": playlist, "client_build": client_build, "protocol_version": protocol_version}, _idempotency_key("queue"))
if err != OK:
state.fail("Could not start matchmaking: %s" % error_string(err))
return err
func recover_queue(ticket_id: String) -> Error:
@@ -102,17 +105,26 @@ func _on_request_completed(result: HTTPRequest.Result, response_code: int, _head
var operation := _operation
_operation = ""
if result != HTTPRequest.RESULT_SUCCESS:
state.fail("Control-plane request failed")
if operation == "queue_create" or operation == "queue_recover":
state.fail("Control-plane request failed")
else:
state.set_notice("Control-plane request failed; retrying is safe")
request_failed.emit(operation, response_code, "network error")
return
var parsed = JSON.parse_string(body.get_string_from_utf8())
if not parsed is Dictionary:
state.fail("Control-plane returned invalid JSON")
if operation == "queue_create" or operation == "queue_recover":
state.fail("Control-plane returned invalid JSON")
else:
state.set_notice("Control-plane returned invalid JSON; retrying is safe")
request_failed.emit(operation, response_code, "invalid JSON")
return
if response_code < 200 or response_code >= 300:
var detail := String(parsed.get("error", "request rejected"))
state.fail(detail)
if operation == "queue_create" or operation == "queue_recover":
state.fail(detail)
else:
state.set_notice(detail)
request_failed.emit(operation, response_code, detail)
return
var payload: Dictionary = parsed