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

The process exit code 0 is incorrect after the fibjs process crashes #775

Open
forchid opened this issue May 11, 2024 · 1 comment
Open

Comments

@forchid
Copy link

forchid commented May 11, 2024

Versions

Fibjs v0.37.0, windows 10 x64.

Test source code

a.b = 'Crash!';

Expected test result

The process exit code is 1.

Fibjs test result

>fibjs crash-exitcode.js
crash-exitcode.js:1:1
a.b = 'Crash!';
^
ReferenceError: a is not defined
    at crash-exitcode.js:1:1

>echo %errorlevel%
0

Node test result

>node crash-exitcode.js
crash-exitcode.js:1
a.b = 'Crash!';
^

ReferenceError: a is not defined
    at Object.<anonymous> (crash-exitcode.js:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.10.0

>echo %errorlevel%
1
@xicilion
Copy link
Member

xicilion commented May 17, 2024

There is a design difference in the details here. In Node.js, any uncaught errors will immediately exit the process; but in FibJS, only errors from the main fiber will exit the process, while errors in other fibers are considered non-serious errors and do not exit the process.

I can change the strategy to exit with code 1 when the main fiber encounters an error(52daaef), but this behavior still differs from Node.js, because there might be errors reported by other fibers while the main fiber exits normally. In that case, should the exit code be 0 or 1? This may need further discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants