This repository was archived by the owner on Feb 16, 2024. It is now read-only.
This repository was archived by the owner on Feb 16, 2024. It is now read-only.
Observable from UnityWebRequest calls OnComplete although status is still InProgress #530
Open
Description
I do the following to observe a UnityWebRequest:
UnityWebRequest unityWebRequest = UnityWebRequest.Get(uri);
void OnNext()
{
Debug.Log($"{unityWebRequest.method} '{unityWebRequest.uri}' has updated. Status: {unityWebRequest.result}, response code: {unityWebRequest.responseCode}");
}
void OnError
{
Debug.LogError($"{unityWebRequest.method} '{unityWebRequest.uri}' has failed. Status: {unityWebRequest.result}, response code: {unityWebRequest.responseCode}, error message: {ex.Message}");
Debug.LogException(ex);
}
void OnComplete()
{
Debug.Log($"{unityWebRequest.method} '{unityWebRequest.uri}' has completed. Status: {unityWebRequest.result}, response code: {unityWebRequest.responseCode}, response body: {unityWebRequest.downloadHandler.text}");
}
unityWebRequest
.SendWebRequest()
.AsAsyncOperationObservable()
.Subscribe(OnSucess, OnError, OnComplete);
My problem is that sometimes (not always) the OnComplete method is called although unityWebRequest.result
is still InProgress
, the unityWebRequest.downloadHandler.text
is empty, and unityWebRequest.isDone
is false.
Thus, OnComplete seems to be called prematurely sometimes.
Is this a bug?
Or do I have to create the Observable from the UnityWebRequest differently somehow?
Metadata
Metadata
Assignees
Labels
No labels