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

ExecSync command fails without any error in the command being executed #4440

Open
2 tasks done
hardikmodi1 opened this issue Jul 5, 2024 · 6 comments
Open
2 tasks done
Labels
needs more info issues that need more info from the author

Comments

@hardikmodi1
Copy link

hardikmodi1 commented Jul 5, 2024

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

  • I have looked for issues that already exist before submitting this
  • 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
@RedYetiDev
Copy link
Member

Can you reproduce this with any command, or is it specifically yarn commands / tsc commands?

@hardikmodi1
Copy link
Author

Tried only with tsc. So I am not sure if it reproducible with the other commands or not 😔

@RedYetiDev
Copy link
Member

Could you possibly verify if it's reproducible with other commands? Does this command execute normally when run via the shell?

@RedYetiDev RedYetiDev added the needs more info issues that need more info from the author label Jul 6, 2024
@hardikmodi1
Copy link
Author

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

@RedYetiDev
Copy link
Member

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

@SsomsakTH
Copy link

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:

  1. 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.
  1. 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.
  1. 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.
  1. Check for environmental problems:
  • Verify that required environment variables are set correctly.
  • Verify that the path to the file used is correct.
  1. Check recording:
  • Check application or operating system log files.
  • Error messages in the log file may help determine the cause of the problem.
  1. Check online resources:
  • Search for similar problems on the internet
  • Sites like Stack Overflow or GitHub may have solutions.
  1. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info issues that need more info from the author
Projects
None yet
Development

No branches or pull requests

3 participants