Skip to content

Commit 569089a

Browse files
committed
fix: Handle exceptions in callbacks gracefully
1 parent 22d44d6 commit 569089a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Runtime/Client/LootLockerHTTPClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,10 @@ private void CallListenersAndMarkDone(LootLockerHTTPExecutionQueueItem execution
566566
executionItem.Done = true;
567567
response.requestContext = new LootLockerRequestContext(executionItem.RequestData.ForPlayerWithUlid, executionItem.RequestData.RequestStartTime);
568568
executionItem.Response = response;
569+
if(!CompletedRequestIDs.Contains(executionItem.RequestData.RequestId)) {
570+
CompletedRequestIDs.Add(executionItem.RequestData.RequestId);
571+
}
569572
executionItem.RequestData.CallListenersWithResult(response);
570-
CompletedRequestIDs.Add(executionItem.RequestData.RequestId);
571573
}
572574

573575
private IEnumerator RefreshSession(string refreshForPlayerUlid, string forExecutionItemId, Action<LootLockerSessionResponse, string, string> onSessionRefreshedCallback)

Runtime/Client/LootLockerHttpRequestData.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ public void CallListenersWithResult(LootLockerResponse response)
8787
{
8888
foreach(var listener in Listeners)
8989
{
90-
listener?.Invoke(response);
90+
try
91+
{
92+
listener?.Invoke(response);
93+
}
94+
catch (Exception e)
95+
{
96+
LootLockerLogger.Log($"Exception thrown in HTTP request listener for request id {RequestId}. Exception was: {e}.", LootLockerLogger.LogLevel.Error);
97+
}
9198
}
9299
HaveListenersBeenInvoked = true;
93100
}

0 commit comments

Comments
 (0)