-
- Notifications
You must be signed in to change notification settings - Fork 33.7k
module: process.exit() should result in exit code 0 #41388
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
Changes from 1 commit
b828eac 5ebf9b0 fab1eed 4e6f2c0 dbf136c 24bc42c adcf374 73e0b71 d58b5b9 d7bb21f 0951516 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| 'use strict'; | ||
| | ||
| function handleProcessExit() { | ||
| if (process.exitCode === undefined) | ||
| process.exitCode = 13; | ||
| } | ||
| | ||
| module.exports = { | ||
| handleProcessExit, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -48,6 +48,10 @@ const { | |
| } = require('internal/validators'); | ||
| const constants = internalBinding('constants').os.signals; | ||
| | ||
| const { | ||
| handleProcessExit | ||
MoonBall marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| } = require('internal/modules/esm/handle_process_exit'); | ||
| Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this logic happens for all code, not just ESM code, should Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It only happens for ESM code, because it's the only place we have TLA in Node.js. Member Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am curious what's the full name of TLA? 🤣 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an acronym for Top Level Await, sorry I was too lazy to type it all out 🙈 | ||
| | ||
| const kInternal = Symbol('internal properties'); | ||
| | ||
| function assert(x, msg) { | ||
| | @@ -175,6 +179,8 @@ function wrapProcessMethods(binding) { | |
| memoryUsage.rss = rss; | ||
| | ||
| function exit(code) { | ||
| process.off('exit', handleProcessExit); | ||
| | ||
| if (code || code === 0) | ||
| process.exitCode = code; | ||
| | ||
| | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| process.exit(); | ||
MoonBall marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { Worker } from 'worker_threads'; | ||
| | ||
| // Do not use isMainThread so that this test itself can be run inside a Worker. | ||
| if (!process.env.HAS_STARTED_WORKER) { | ||
| process.env.HAS_STARTED_WORKER = 1; | ||
MoonBall marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| new Worker(import.meta.url.slice('file://'.length)); | ||
MoonBall marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| await new Promise(() => {}); | ||
| } else { | ||
| process.exit() | ||
MoonBall marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.