JSImport returning Promise that signals reject #102339
Labels
arch-wasm
WebAssembly architecture
area-System.Runtime.InteropServices.JavaScript
os-browser
Browser variant of arch-wasm
Milestone
Description
What's expected if a I call a JSImport method which returns a promise, and the promise signals a reject?
This code works fine when it signals resolve, but if it signals reject it hangs on the await'd ConditionalSuccess() call. Neither the "Error occurred" nor the "More?" message prints, and if F10 each line it never returns from the ConditionalSuccess().
Is this not supported, or am I doing something wrong?
I also tried .ContinueWith() and checking for a faulted task, but the ContinueWith is never called. I assume workaround would be to handle reject's JS-side, and throw instead.
Reproduction Steps
Create a wasm-browser project, define the following JS in a ES6 module, load the module with JSHost.ImportAsync, then call the below C# code.
Expected behavior
Maybe return a faulted task or throw an exception? I'm not a expert on Promises so I wouldn't presume to know what should happen. But I feel confident that it definitely shouldn't just hang.
Actual behavior
The call to PromisesProxy.ConditionalSuccess() hangs and never returns if the JS Promise calls reject()
Regression?
No response
Known Workarounds
Pass string into
.reject()
Configuration
VS 17.10.0 Preview 3
dotnet --info:
.NET SDK:
Version: 8.0.300-preview.24203.14
Commit: b7e38f457d
Workload version: 8.0.300-manifests.c4df6daf
MSBuild version: 17.10.0+4f6b1bb28
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.300-preview.24203.14\
.NET workloads installed:
[aspire]
Installation Source: SDK 8.0.300-preview.24203, VS 17.10.34804.81
Manifest Version: 8.0.0-preview.5.24201.12/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.0.0-preview.5.24201.12\WorkloadManifest.json
Install Type: Msi
[wasm-experimental]
Installation Source: SDK 8.0.300-preview.24203
Manifest Version: 8.0.4/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.4\WorkloadManifest.json
Install Type: Msi
[wasm-tools]
Installation Source: SDK 8.0.300-preview.24203
Manifest Version: 8.0.4/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.4\WorkloadManifest.json
Install Type: Msi
Host:
Version: 8.0.4
Architecture: x64
Commit: 2d7eea2
.NET SDKs installed:
6.0.321 [C:\Program Files\dotnet\sdk]
6.0.400 [C:\Program Files\dotnet\sdk]
6.0.406 [C:\Program Files\dotnet\sdk]
8.0.104 [C:\Program Files\dotnet\sdk]
8.0.204 [C:\Program Files\dotnet\sdk]
8.0.300-preview.24203.14 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other information
No response
The text was updated successfully, but these errors were encountered: