Skip to content

Commit 57974e6

Browse files
authored
Fix ToPromise not returning when faulted
ToPromise was not properly calling `reject` when an exception was encountered.
1 parent 19ca67c commit 57974e6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ClearScript/JavaScript/JavaScriptExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static object ToPromise<TResult>(this Task<TResult> task, ScriptEngine en
4545
{
4646
task.ContinueWith(thisTask =>
4747
{
48-
if (thisTask.IsCompleted)
48+
if (thisTask.IsCompleted && !thisTask.IsCanceled && !thisTask.IsFaulted)
4949
{
5050
resolve(thisTask.Result);
5151
}
@@ -87,7 +87,7 @@ public static object ToPromise(this Task task, ScriptEngine engine)
8787
{
8888
task.ContinueWith(thisTask =>
8989
{
90-
if (thisTask.IsCompleted)
90+
if (thisTask.IsCompleted && !thisTask.IsCanceled && !thisTask.IsFaulted)
9191
{
9292
resolve();
9393
}

0 commit comments

Comments
 (0)