Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm] Invoking async [JSExport] and [JSImport] kills the process on node, but works in browser #92713

Closed
elringus opened this issue Sep 27, 2023 · 2 comments · Fixed by #92871
Assignees
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm
Milestone

Comments

@elringus
Copy link

elringus commented Sep 27, 2023

Given following in C#:

public static partial class Program
{
    public static void Main () { }

    [JSExport]
    public static Task TestAsyncVoid () => Task.Delay(1);
}

When invoking the method in node:

const runtime = await dotnet.withExitCodeLogging().withConfig(config).create();
await runtime.runMain("EntryAssembly.dll", []);
const exports = await runtime.getAssemblyExports("EntryAssembly.dll");
await exports.Program.TestAsyncVoid();
console.log("finished");

— runtime exits without printing "finished" with the following log:

WASM EXIT undefined
WASM EXIT 0

Same story with async [JSImport]'s. Basically, any kind of concurrency doesn't work in node.

I've also tried testing with bun, but it behaved the same.

At the same time all this works fine in browser.

Is there something I'm missing? Maybe some kind of switch or option when creating the runtime?

Here is the repro (breaks on async calls in node, but works fine in browser): https://github.com/Elringus/JSInteropTest

.NET 8 RC1
NodeJS v20.5.1

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 27, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 27, 2023
@jkoritzinsky jkoritzinsky added area-System.Runtime.InteropServices.JavaScript and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 27, 2023
@radical radical added the arch-wasm WebAssembly architecture label Sep 28, 2023
@ghost
Copy link

ghost commented Sep 28, 2023

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Given following in C#:

public static partial class Program
{
    public static void Main () { }

    [JSExport]
    public static Task TestAsyncVoid () => Task.Delay(1);
}

When invoking the method in node:

const runtime = await dotnet.withExitCodeLogging().withConfig(config).create();
await runtime.runMain("EntryAssembly.dll", []);
const exports = await runtime.getAssemblyExports("EntryAssembly.dll");
await exports.Program.TestAsyncVoid();
console.log("finished");

— runtime exits without printing "finished" with the following log:

WASM EXIT undefined
WASM EXIT 0

Same story with async [JSImport]'s. Basically, any kind of concurrency doesn't work in node.

I've also tried testing with bun, but it behaved the same.

At the same time all this works fine in browser.

Is there something I'm missing? Maybe some kind of switch or option when creating the runtime?

Here is the repro (breaks on async calls in node, but works fine in browser): https://github.com/Elringus/JSInteropTest

.NET 8 RC1
NodeJS v20.5.1

Author: Elringus
Assignees: -
Labels:

arch-wasm, untriaged, area-System.Runtime.InteropServices.JavaScript

Milestone: -

@radical
Copy link
Member

radical commented Sep 28, 2023

cc @pavelsavara

@pavelsavara pavelsavara added the os-browser Browser variant of arch-wasm label Sep 29, 2023
@pavelsavara pavelsavara added this to the 8.0.0 milestone Sep 29, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Sep 29, 2023
pavelsavara added a commit to pavelsavara/runtime that referenced this issue Oct 2, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Oct 2, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Oct 2, 2023
github-actions bot pushed a commit that referenced this issue Oct 2, 2023
carlossanlop pushed a commit that referenced this issue Oct 3, 2023
Co-authored-by: pavelsavara <pavel.savara@gmail.com>
dotnet-bot pushed a commit to dotnet/dotnet that referenced this issue Oct 3, 2023
Diff: https://github.com/dotnet/runtime/compare/b20f704cc00f390e5560a137deb8f0e64e863e1d..ef6283ac0a14c78d9e9fef4841545099bd7ad12b

From: dotnet/runtime@b20f704
To: dotnet/runtime@ef6283a

Commits:
  - Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230928.3 (#92816)
    dotnet/runtime@f1e4e90
  - Changes from dotnet/runtime#92630 (#92753)
    dotnet/runtime@8632a75
  - [release/8.0] [browser] Remove duplicated marshaling of return value for JSExport (#92886)
    dotnet/runtime@172d79a
  - fix dotnet/runtime#92713 (#92890)
    dotnet/runtime@8e365ee
  - [release/8.0] Update dependencies from dotnet/roslyn (#92503)
    dotnet/runtime@ef6283a

[[ commit created by automation ]]
mthalman pushed a commit to mthalman/dotnet that referenced this issue Oct 25, 2023
Diff: https://github.com/dotnet/runtime/compare/b20f704cc00f390e5560a137deb8f0e64e863e1d..ef6283ac0a14c78d9e9fef4841545099bd7ad12b

From: dotnet/runtime@b20f704
To: dotnet/runtime@ef6283a

Commits:
  - Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230928.3 (#92816)
    dotnet/runtime@f1e4e90
  - Changes from dotnet/runtime#92630 (#92753)
    dotnet/runtime@8632a75
  - [release/8.0] [browser] Remove duplicated marshaling of return value for JSExport (#92886)
    dotnet/runtime@172d79a
  - fix dotnet/runtime#92713 (#92890)
    dotnet/runtime@8e365ee
  - [release/8.0] Update dependencies from dotnet/roslyn (#92503)
    dotnet/runtime@ef6283a

[[ commit created by automation ]]
@ghost ghost locked as resolved and limited conversation to collaborators Nov 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm
Projects
None yet
5 participants