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] NodeJS samples failing at exit with emsdk 2.0.34 #64727

Closed
radical opened this issue Feb 3, 2022 · 5 comments · Fixed by #64734
Closed

[wasm] NodeJS samples failing at exit with emsdk 2.0.34 #64727

radical opened this issue Feb 3, 2022 · 5 comments · Fixed by #64734
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono disabled-test The test is disabled in source code against the issue

Comments

@radical
Copy link
Member

radical commented Feb 3, 2022

Hit on #62499 . Build.

Fails for both CJS, and ES6 in the same way:

[02:11:49] fail: undefined
[02:11:49] fail: (Use `node --trace-uncaught ...` to show where the exception was thrown)
[02:11:49] info: Process node exited with 7

Running locally with --trace-uncaught:

undefined
Thrown at:
    at /Users/radical/dev/runtime/src/mono/sample/wasm/console-node-cjs/bin/Release/AppBundle/dotnet.js:12:2969
    at emit (node:events:394:28)
    at node:internal/process/execution:170:25

Seems to be because of undefined quit_ function.

cc @pavelsavara

Build Kind Start Time
1589203 Rolling 2022-03-02
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Feb 3, 2022
@radical radical added arch-wasm WebAssembly architecture and removed untriaged New issue has not been triaged by the area owner labels Feb 3, 2022
@ghost
Copy link

ghost commented Feb 3, 2022

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

Issue Details

Hit on #62499 . Build.

Fails for both CJS, and ES6 in the same way:

[02:11:49] fail: undefined
[02:11:49] fail: (Use `node --trace-uncaught ...` to show where the exception was thrown)
[02:11:49] info: Process node exited with 7

Running locally with --trace-uncaught:

undefined
Thrown at:
    at /Users/radical/dev/runtime/src/mono/sample/wasm/console-node-cjs/bin/Release/AppBundle/dotnet.js:12:2969
    at emit (node:events:394:28)
    at node:internal/process/execution:170:25

Seems to be because of undefined quit_ function.

cc @pavelsavara

Author: radical
Assignees: -
Labels:

arch-wasm

Milestone: -

@pavelsavara
Copy link
Member

I'm stealing _quit from inside emscripten here. Perhaps they have replacement ?

Also, if the replacement could be exported with EXPORTED_RUNTIME_METHODS or EXPORTED_FUNCTIONS it would be much better than what we have now.

@radekdoulik
Copy link
Member

I am able to reproduce it locally. The undefined comes from:

        process["on"]("uncaughtException", function (ex) {
            console.log(`ex: ${ex}`);
            if (!(ex instanceof ExitStatus)) {
                throw ex;
            }
        });

the console output:

node --trace-uncaught .\main.cjs
Debugger.Debug: DEBUGGING ENABLED

mono_wasm_runtime_ready fe00e07a-5519-4dfe-b35a-f867dbaf2e28
Hello World!
ex: undefined

C:\Users\rodo\git\wa-main\src\mono\sample\wasm\console-node-cjs\bin\Release\AppBundle\dotnet.js:4190
                    throw ex;
                    ^
undefined
Thrown at:
    at C:\Users\rodo\git\wa-main\src\mono\sample\wasm\console-node-cjs\bin\Release\AppBundle\dotnet.js:4190:21
    at emit (node:events:378:20)
    at node:internal/process/execution:163:25

@radekdoulik
Copy link
Member

radekdoulik commented Feb 3, 2022

I think the issue here is that quit_ is called twice:

Debugger.Debug: DEBUGGING ENABLED

mono_wasm_runtime_ready fe00e07a-5519-4dfe-b35a-f867dbaf2e28
Hello World!
quit_ function
status: 42
quit_ function
status: 1
Trace
    at process.<anonymous> (C:\Users\rodo\git\wa-main\src\mono\sample\wasm\console-node-cjs\bin\Release\AppBundle\dotnet.js:4189:25)
    at process.emit (node:events:378:20)
    at process._fatalException (node:internal/process/execution:163:25)
ex: undefined

C:\Users\rodo\git\wa-main\src\mono\sample\wasm\console-node-cjs\bin\Release\AppBundle\dotnet.js:4192
                    throw ex;
                    ^
undefined
Thrown at:
    at C:\Users\rodo\git\wa-main\src\mono\sample\wasm\console-node-cjs\bin\Release\AppBundle\dotnet.js:4192:21
    at emit (node:events:378:20)
    at node:internal/process/execution:163:25

The code:

            quit_ = function (status, toThrow) {
                console.log("quit_ function");
                if (keepRuntimeAlive()) {
                    process["exitCode"] = status;
                    console.log(`status: ${status}`);
                    throw toThrow;
                }
                console.log(`toThrow: ${toThrow}`);
                logExceptionOnExit(toThrow);
                process["exit"](status);
            };

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 3, 2022
@pavelsavara pavelsavara self-assigned this Feb 3, 2022
@radical radical added the disabled-test The test is disabled in source code against the issue label Feb 4, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 4, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono disabled-test The test is disabled in source code against the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants