Skip to content

Commit 169cab9

Browse files
Copilotilonatommy
andcommitted
Replace JSTimeoutException with TimeoutException per feedback
Co-authored-by: ilonatommy <[email protected]>
1 parent 941f88e commit 169cab9

File tree

6 files changed

+3
-63
lines changed

6 files changed

+3
-63
lines changed

src/Components/Components/src/ComponentBase.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Microsoft.AspNetCore.Components.Rendering;
5-
using Microsoft.JSInterop;
65

76
namespace Microsoft.AspNetCore.Components;
87

@@ -290,11 +289,6 @@ private async Task RunInitAndSetParametersAsync()
290289
{
291290
await task;
292291
}
293-
catch (JSTimeoutException)
294-
{
295-
// Let JSTimeoutException bubble up to provide meaningful error information
296-
throw;
297-
}
298292
catch // avoiding exception filters for AOT runtime support
299293
{
300294
// Ignore exceptions from task cancellations.
@@ -338,11 +332,6 @@ private async Task CallStateHasChangedOnAsyncCompletion(Task task)
338332
{
339333
await task;
340334
}
341-
catch (JSTimeoutException)
342-
{
343-
// Let JSTimeoutException bubble up to provide meaningful error information
344-
throw;
345-
}
346335
catch // avoiding exception filters for AOT runtime support
347336
{
348337
// Ignore exceptions from task cancellations, but don't bother issuing a state change.

src/Components/Components/test/ComponentBaseTest.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Diagnostics;
55
using Microsoft.AspNetCore.Components.Rendering;
66
using Microsoft.AspNetCore.Components.Test.Helpers;
7-
using Microsoft.JSInterop;
87

98
namespace Microsoft.AspNetCore.Components.Test;
109

@@ -464,24 +463,6 @@ public async Task RenderRootComponentAsync_ReportsErrorDuringOnParameterSetAsync
464463
Assert.Same(expected, actual);
465464
}
466465

467-
[Fact]
468-
public async Task ComponentBase_AllowsJSTimeoutExceptionToBubbleUp()
469-
{
470-
// Arrange
471-
var renderer = new TestRenderer();
472-
var component = new TestComponent();
473-
474-
var timeoutException = new JSTimeoutException("Test timeout");
475-
component.OnParametersSetAsyncLogic = _ => Task.FromException(timeoutException);
476-
477-
// Act & Assert
478-
var componentId = renderer.AssignRootComponentId(component);
479-
var actual = await Assert.ThrowsAsync<JSTimeoutException>(() => renderer.RenderRootComponentAsync(componentId));
480-
481-
// Assert
482-
Assert.Same(timeoutException, actual);
483-
}
484-
485466
private class TestComponent : ComponentBase
486467
{
487468
public bool RunsBaseOnInit { get; set; } = true;

src/JSInterop/Microsoft.JSInterop/src/JSRuntime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public ValueTask<IJSObjectReference> InvokeNewAsync(string identifier, Cancellat
122122
catch (OperationCanceledException) when (cts.Token.IsCancellationRequested)
123123
{
124124
// This was cancelled due to our timeout, throw a more meaningful exception
125-
throw new JSTimeoutException("A JavaScript interop call timed out. Consider increasing the timeout duration if the operation is expected to take longer.");
125+
throw new TimeoutException("A JavaScript interop call timed out. Consider increasing the timeout duration if the operation is expected to take longer.");
126126
}
127127
}
128128

src/JSInterop/Microsoft.JSInterop/src/JSTimeoutException.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/JSInterop/Microsoft.JSInterop/src/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ Microsoft.JSInterop.JSRuntime.InvokeNewAsync(string! identifier, object?[]? args
5454
Microsoft.JSInterop.JSRuntime.InvokeNewAsync(string! identifier, System.Threading.CancellationToken cancellationToken, object?[]? args) -> System.Threading.Tasks.ValueTask<Microsoft.JSInterop.IJSObjectReference!>
5555
Microsoft.JSInterop.JSRuntime.SetValueAsync<TValue>(string! identifier, TValue value) -> System.Threading.Tasks.ValueTask
5656
Microsoft.JSInterop.JSRuntime.SetValueAsync<TValue>(string! identifier, TValue value, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask
57-
Microsoft.JSInterop.JSTimeoutException
58-
Microsoft.JSInterop.JSTimeoutException.JSTimeoutException(string! message) -> void
59-
Microsoft.JSInterop.JSTimeoutException.JSTimeoutException(string! message, System.Exception! innerException) -> void
6057
static Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeNewAsync(this Microsoft.JSInterop.IJSObjectReference! jsObjectReference, string! identifier, params object?[]? args) -> System.Threading.Tasks.ValueTask<Microsoft.JSInterop.IJSObjectReference!>
6158
static Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeNewAsync(this Microsoft.JSInterop.IJSObjectReference! jsObjectReference, string! identifier, System.Threading.CancellationToken cancellationToken, object?[]? args) -> System.Threading.Tasks.ValueTask<Microsoft.JSInterop.IJSObjectReference!>
6259
static Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeNewAsync(this Microsoft.JSInterop.IJSObjectReference! jsObjectReference, string! identifier, System.TimeSpan timeout, object?[]? args) -> System.Threading.Tasks.ValueTask<Microsoft.JSInterop.IJSObjectReference!>

src/JSInterop/Microsoft.JSInterop/test/JSRuntimeTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void DispatchesAsyncCallsWithDistinctAsyncHandles()
3737
}
3838

3939
[Fact]
40-
public async Task InvokeAsync_ThrowsJSTimeoutException_AfterDefaultTimeout()
40+
public async Task InvokeAsync_ThrowsTimeoutException_AfterDefaultTimeout()
4141
{
4242
// Arrange
4343
var runtime = new TestJSRuntime();
@@ -47,7 +47,7 @@ public async Task InvokeAsync_ThrowsJSTimeoutException_AfterDefaultTimeout()
4747
var task = runtime.InvokeAsync<object>("test identifier 1", "arg1", 123, true);
4848

4949
// Assert
50-
await Assert.ThrowsAsync<JSTimeoutException>(async () => await task);
50+
await Assert.ThrowsAsync<TimeoutException>(async () => await task);
5151
}
5252

5353
[Fact]

0 commit comments

Comments
 (0)