ExecSync command fails without any error in the command being executed
Node.js Version
v18.18.2
NPM Version
v9.8.1
Operating System
Linux
Subsystem
child_process
Description
I am running tsc command using execSync with in gitlab pipelines. In most of the cases it works fine. But sometimes it fails without giving any error regarding tsc. Command I am executing is
execSync("yarn tsc", { stdio: 'inherit' });
I have wrapped this command in try catch and printed the exception, In cases where it fails it only prints following thing on console
Error: Command failed: yarn tsc
at checkExecSyncError (node:child_process:890:11)
at execSync (node:child_process:962:15)
at /builds/scripts/tsc.ts:30:13
at step (/builds/scripts/tsc.ts:44:23) {
status: 129,
signal: null,
output: [ null, null, null ],
pid: [204],
stdout: null,
stderr: null
}
Just rerunning the pipeline without any changes in the code this works fine.
Minimal Reproduction
No response
Output
No response
Before You Submit
- [X] I have looked for issues that already exist before submitting this
- [X] My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask
Can you reproduce this with any command, or is it specifically yarn commands / tsc commands?
Tried only with tsc. So I am not sure if it reproducible with the other commands or not 😔
Could you possibly verify if it's reproducible with other commands? Does this command execute normally when run via the shell?
Yes if I run via shell then it executes normally, even if I just retrigger the pipeline it works fine. It fails randomly with the given error
My gut feeling is that it's a yarn issue, given the fact it returned an exit code (129), but I'm not 100% sure.
@nodejs/child_process PTAL
ExecSync is understood to be having issues, failing without errors on the commands it is executing. It created a lot of problems. Try these steps to find the cause and fix the problem:
- Check the exit status:
- Check the status value of ExecSync results.
- A flag other than 0 indicates that an error occurred.
- Use console.error Print flags and error messages.
- Verify input:
- Make sure the ExecSync command is correct.
- Check grammar and upper/lower case letters.
- Verify that the path to the file used is correct.
- Check access rights:
- Verify that the user account using ExecSync has access to the required files and directories.
- Try using sudo to run commands with administrator rights.
- Check for environmental problems:
- Verify that required environment variables are set correctly.
- Verify that the path to the file used is correct.
- Check recording:
- Check application or operating system log files.
- Error messages in the log file may help determine the cause of the problem.
- Check online resources:
- Search for similar problems on the internet
- Sites like Stack Overflow or GitHub may have solutions.
- Ask for help:
- If the problem still cannot be solved Please ask your developer or IT professional for help. note:
- Additional information about ExecSync may be found in the documentation of the library or framework used.
- Information about specific problems and solutions may be found on the support website of the software or operating system being used. Additional resources:
- Node.js child_process documentation
- Stack Overflow: execSync failed.
- GitHub: ExecSync issue [invalid URL removed] Hope this information helps fix your ExecSync issues!
It's probably a yarn issue, given that other commands work