-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(misc): handle null exit codes from crashed child processes #33163
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
View your CI Pipeline Execution ↗ for commit 1184968
☁️ Nx Cloud last updated this comment at |
d4817cb
to
a5b04dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nx Cloud is proposing a fix for your failed CI:
We've updated the signalToCode
function signature to accept NodeJS.Signals | null
instead of just NodeJS.Signals
, which resolves the TypeScript compilation error. When the signal is null, the function now returns exit code 1 as a sensible default for crashed processes.
We verified this fix by re-running create-nx-workspace:test
.
Suggested Fix changes
diff --git a/packages/create-nx-workspace/src/utils/child-process-utils.ts b/packages/create-nx-workspace/src/utils/child-process-utils.ts
index 9fa3e6cab5..8a508352fb 100644
--- a/packages/create-nx-workspace/src/utils/child-process-utils.ts
+++ b/packages/create-nx-workspace/src/utils/child-process-utils.ts
@@ -60,7 +60,10 @@ export function execAndWait(
});
}
-function signalToCode(signal: NodeJS.Signals): number {
+function signalToCode(signal: NodeJS.Signals | null): number {
+ if (signal === null) {
+ return 1;
+ }
switch (signal) {
case 'SIGHUP':
return 128 + 1;
diff --git a/packages/nx/src/utils/exit-codes.ts b/packages/nx/src/utils/exit-codes.ts
index 309ab8aafc..0f23124ae4 100644
--- a/packages/nx/src/utils/exit-codes.ts
+++ b/packages/nx/src/utils/exit-codes.ts
@@ -2,7 +2,10 @@
* Translates NodeJS signals to numeric exit code
* @param signal
*/
-export function signalToCode(signal: NodeJS.Signals): number {
+export function signalToCode(signal: NodeJS.Signals | null): number {
+ if (signal === null) {
+ return 1;
+ }
switch (signal) {
case 'SIGHUP':
return 128 + 1;
Or Apply changes locally with:
npx nx-cloud apply-locally 4Ns9-rr3U
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 To learn more about Self Healing CI, please visit nx.dev
a5b04dc
to
1184968
Compare
Current Behavior
In some scenarios, when some processes terminate unexpectedly (e.g. crashed due to OOM), the task runner will incorrectly determine their exit code to be 0. This results in Nx storing the task results as a success, which can cause cache hits with false positive successes.
Expected Behavior
When processes terminate unexpectedly (e.g. crashed due to OOM), the task runner should correctly determine their exit code from the signal, and it should never be 0. The stored task result should not be marked as successful.
Related Issue(s)
Fixes #29204