From a162b094c2806f7e5ea8715469ca184001d8a848 Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad Date: Sat, 22 Nov 2025 12:16:08 +0600 Subject: [PATCH 1/3] [fix]: properly handle `ArgumentNullException` for abort controller; - ref #103 --- .../Helpers/RequestHelperExtension.cs | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/src/Proyecto26.RestClient/Helpers/RequestHelperExtension.cs b/src/Proyecto26.RestClient/Helpers/RequestHelperExtension.cs index 7017a74..fadc6c3 100644 --- a/src/Proyecto26.RestClient/Helpers/RequestHelperExtension.cs +++ b/src/Proyecto26.RestClient/Helpers/RequestHelperExtension.cs @@ -20,7 +20,15 @@ public float UploadProgress float progress = 0; if (this.Request != null) { - progress = this.Request.uploadProgress; + try + { + progress = this.Request.uploadProgress; + } + catch (ArgumentNullException) + { + // Request was disposed - return 0 progress + progress = 0; + } } return progress; } @@ -36,7 +44,15 @@ public ulong UploadedBytes ulong bytes = 0; if (this.Request != null) { - bytes = this.Request.uploadedBytes; + try + { + bytes = this.Request.uploadedBytes; + } + catch (ArgumentNullException) + { + // Request was disposed - return 0 bytes + bytes = 0; + } } return bytes; } @@ -52,7 +68,15 @@ public float DownloadProgress float progress = 0; if (this.Request != null) { - progress = this.Request.downloadProgress; + try + { + progress = this.Request.downloadProgress; + } + catch (ArgumentNullException) + { + // Request was disposed - return 0 progress + progress = 0; + } } return progress; } @@ -68,7 +92,15 @@ public ulong DownloadedBytes ulong bytes = 0; if (this.Request != null) { - bytes = this.Request.downloadedBytes; + try + { + bytes = this.Request.downloadedBytes; + } + catch (ArgumentNullException) + { + // Request was disposed - return 0 bytes + bytes = 0; + } } return bytes; } @@ -81,10 +113,18 @@ public ulong DownloadedBytes /// The name of the header. public string GetHeader(string name) { - string headerValue; + string headerValue = null; if (this.Request != null) { - headerValue = this.Request.GetRequestHeader(name); + try + { + headerValue = this.Request.GetRequestHeader(name); + } + catch (ArgumentNullException) + { + // Request was disposed - fall back to headers dictionary + this.Headers.TryGetValue(name, out headerValue); + } } else { @@ -131,6 +171,12 @@ public void Abort() this.Request.Abort(); } } + catch (ArgumentNullException) + { + // Request was already disposed by UnityWebRequest's using block - this is expected behavior + // No need to log this as it's a normal part of the request lifecycle + HttpBase.DebugLog(this.EnableDebug, "Request was already disposed; abort skipped.", true); + } catch (Exception error) { HttpBase.DebugLog(this.EnableDebug, error.Message, true); } From be566ca2d6e881e892ae912fc78717e465e4ce2c Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad Date: Sat, 22 Nov 2025 12:16:53 +0600 Subject: [PATCH 2/3] [version]: set to `2.6.3`; --- src/Proyecto26.RestClient/Proyecto26.RestClient.csproj | 2 +- src/Proyecto26.RestClient/RestClient.cs | 2 +- src/Proyecto26.RestClient/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Proyecto26.RestClient/Proyecto26.RestClient.csproj b/src/Proyecto26.RestClient/Proyecto26.RestClient.csproj index 9c255c1..edecf9f 100644 --- a/src/Proyecto26.RestClient/Proyecto26.RestClient.csproj +++ b/src/Proyecto26.RestClient/Proyecto26.RestClient.csproj @@ -9,7 +9,7 @@ Proyecto26.RestClient v3.5 Proyecto26.RestClient - 2.6.2 + 2.6.3 jdnichollsc https://github.com/proyecto26/RestClient/blob/master/img/icono.png?raw=true https://github.com/proyecto26/RestClient/blob/master/LICENSE diff --git a/src/Proyecto26.RestClient/RestClient.cs b/src/Proyecto26.RestClient/RestClient.cs index 82b0da5..2fbdd04 100644 --- a/src/Proyecto26.RestClient/RestClient.cs +++ b/src/Proyecto26.RestClient/RestClient.cs @@ -23,7 +23,7 @@ public static System.Version Version get { if (_version == null) { - _version = new System.Version("2.6.2"); + _version = new System.Version("2.6.3"); } return _version; } diff --git a/src/Proyecto26.RestClient/package.json b/src/Proyecto26.RestClient/package.json index 29f6577..e71dc6f 100644 --- a/src/Proyecto26.RestClient/package.json +++ b/src/Proyecto26.RestClient/package.json @@ -1,6 +1,6 @@ { "name": "com.proyecto26.restclient", - "version": "2.6.2", + "version": "2.6.3", "displayName": "RestClient for Unity", "description": "Simple HTTP and REST client for Unity based on Promises, also support Callbacks!", "unity": "2017.1", From 2f831dc323a2205235f5ecc18bea687d315617ac Mon Sep 17 00:00:00 2001 From: Maifee Ul Asad Date: Sat, 22 Nov 2025 12:18:00 +0600 Subject: [PATCH 3/3] [chores]: updated changelog w ref of #103; --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d69e6..57fd1f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.6.3] - 2025-11-22 + +### Fixed +- Fixed **ArgumentNullException** when calling `Abort()` or accessing properties on completed requests ([#103](https://github.com/proyecto26/RestClient/issues/103)). +- Enhanced disposal detection for UnityWebRequest objects to prevent crashes during cleanup scenarios. +- Added proper exception handling for all RequestHelper properties that access disposed UnityWebRequest instances. +- Improved thread safety for request cancellation in Unity's OnDestroy patterns. + ## [2.6.2] - 2021-12-26 ### Added