-
Notifications
You must be signed in to change notification settings - Fork 739
Add the exit code to the fatal error thrown from common.error(). #1179
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
Add the exit code to the fatal error thrown from common.error(). #1179
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1179 +/- ##
=======================================
Coverage 97.28% 97.28%
=======================================
Files 36 36
Lines 1361 1364 +3
=======================================
+ Hits 1324 1327 +3
Misses 37 37 ☔ View full report in Codecov by Sentry. |
5f5d8f2
to
9ac4236
Compare
@nfischer I've tried many variations including removing my changes, and it seems the problem is between the shelljs dependencies and node 22.13.1, or perhaps anything beyond v22.9.0, where limiting to node v22.9.0 works locally. Is it possible limit the node 22 could tests to 22.9.0 until the deeper dependency issues can be resolved? If we can limit the build tests to 22.9.0 then at least some small improvements could be added while the deeper compatibility issues with node@22 are investigated and resolved. Thanks for your insight and support! |
@kmashint can you file a new bug to share details about things being broken on Node 22? This sort of thing happens from time to time, I'll see what I can do to fix it. I'll look through your PR when I get a chance. |
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.
Can you please add a unit test for this? test/config.js
would be a good place for this. I think you can do something like calling shell.exec('exit 2')
, catch the exception, and check that it has the .code
property. Remember to unset shell.config.fatal
at the end of the test (preferably in a finally
block).
Thanks @nfischer , I've made adjustments to this. I had a successful test with node@22.9.0, 22.10.0 onward have this new compatibility issue, on Ubuntu and OSX related to the 128SIGINT combination that stems from foreground-child@2.0.0 index.js where the signal resolves like a string not a number. As you noted, I'll create a separate issue for this.
On Windows I receive a more cryptic error, which I assume is also related to the signal.
|
I haven't worked with Ava tests, but have with Jest and Jasmine. Jasmine has had a resurgence for its simplicity, and the latest Jest is more than 4x the size of Ava. Jasmine is the safest against external dependency conflicts with only one, glob, but I'm not familiar enough with Ava to make comparisons. The latest Ava is down to 180 nested deps, much better than at 1.4.1. Once of the great differentiators of shelljs is the frugality of its dependencies and it covers the common uses with little fuss. I have another PR brewing for Promise support via, say, $ npm view jasmine@5.6.0 dependencies $ npx howfat jasmine@5.6.0 $ npx howfat ava@6.2.0 $ npx howfat ava@1.4.1 $ npx howfat jest@29 $ npx howfat tape |
f1e804a
to
5732b8a
Compare
3cdd71f
to
1944f81
Compare
Sorry for the confusion from a lingering commit from trying different branches. I've cleaned up the commits and added another test variation since the code coverage complained. Tests pass now with the 22.9.0 limiter, and I'll leave it to you to close the conversations after verifying. Thanks! |
Dropping support for everything before node v18, which is the current maintenance LTS and also the version in Ubuntu 24.04 LTS. This also drops support for odd-numbered node versions since I only want to officially support Node LTS going forward. Non-LTS node support can be supported by the community if necessary. This also updates all devDependencies while trying to minimize the required source code changes. Some devDependencies can go higher still (ava, chalk), but this is going to require extensive refactoring. Test: npm run test-with-coverage Test: npm run lint Test: npm run check-node-support
81a73e0
to
c735322
Compare
c735322
to
87f3a16
Compare
Thanks for the contribution! This should be part of the 0.9.0 release when that eventually goes out. |
While
shelljs.exec(cmd)
on fatal errors does have the exit code in the logEntry message, it's not available as a separate property on the thrown Error instance. The only way to find the exit code on a fatal thrown error is torequire('shelljs/src/common.js').state.errorCode
, an awkward use of an internal.This adds the code from options.code, also used to set the internal state.errorCode, to the options.fatal error before throwing it, simplifying the ability to
shelljs.exit(err.code)
when catching the Error. This is similar to how the child_process.exec() has a code on the err object given to its callback, e.g. in src/exec.js execASync().This updates the package.json to an assumed 0.8.6 since the latest release is 0.8.5.
Something seems to be wrong with node 22.x builds over 22.9, causing errors with npm. I downgraded locally on Win10 to node 22.9 and it ran without this low-level crash.
tinymce/tinymce#10018
From Ubuntu errors, the problem is on the signal handling in foreground-child@2.0.0 index.js where the signal resolves like a string not a number.
npm ls foreground-child
indicates this comes via thenyc
dependency which has a new version 17.1.0 that requires newer foreground-child@3.3.0. But underlying that is spawn-wrap@2.0.0 that has no newer version and uses the problematic foreground-child@2.0.0. I tried forcing some overrides and directly replacing versions but it's still broken with the node 22.14.0, as it is with 22.13.1 in the cloud build. There are also version conflicts where foreground-child@3.3.0 wants signal-exit@3 while spawn-wrap@2 and other dependencies want signal-exit@3.