Npm error 116 (syscall write)

How to ignore the syscall write npm error 116

  • I have some CI job that failed due to this below error (as image below) even all the events and npm script passed. Sometimes I re-tried the failed jobs and it passed. Someone said it is the OOM problem. So I come here looking for a method that ignore the 116 error and return the right correct result of CI job.

Solution

  • At the first try, I created a result.sh file that return exit code 1/0 based on some conditions and execute that file via script in packpage.json along with the npm script which return 116 error. But it seems not work. The error still happen. The script is going like
    “job” : “test file.ci.conf.js ; bash result.sh”

Help

  • As the title, I’m looking for a way that prevent npm ERR! syscall write to happen or ignore it when happened. If you have been in my situation before, please let me know your solution. Thank all of you very much. Have a nice day!

Versions

  • nodejs v16.19.1
  • npm v8.19.3

Thanks for taking the time to be thorough in your request, it really helps! :blush:

Hi,
I am not sure if you have done, why dont you go with:

npm run job || echo "failed with status code $(echo $?)" && echo "do smth else"

or simply

npm run job || true

i dont want to use the param || true at the end of script. Other wise, i try this
|| if [[ $? -eq 1 && $(tail -n 1 npm-debug.log 2>/dev/null) == *"npm ERR! code UNKNOWN"* ]]; then echo "Ignoring UNKNOWN error"; else exit $?; fi
but it still not work, does my script was wrong?

Not sure now what are you trying to achieve, but looking at your code:
regarding 116

npm run somescript || { EXIT_CODE=$?; [[ $EXIT_CODE -eq 116 ]] && echo "116 error, continue working" && "some more commands" || (echo "Exiting with code $EXIT_CODE" && exit $EXIT_CODE); }

your example with exit 1(not sure what you are trying to achieve here, except for catching unknown error whe status code equals 1)

npm run somescript || { EXIT_CODE=$?; [[ $EXIT_CODE -eq 1 && $(tail -n 1 npm-debug.log 2>/dev/null) == *"npm ERR! code UNKNOWN"* ]] && echo "Ignoring UNKNOWN error" || (echo "Exiting with code $EXIT_CODE" && exit $EXIT_CODE); }

@ngocbinhnguyen recently we upgraded to angular 15, node 16.20.2 version and we are getting the same error, As you mentioned we get this error once all build steps are completed successfully. Its passing sometimes intermittently. We don’t have any reason and root cause for this behavior. Were you able to resolve it ? I can see you are trying to exit process gracefully so that it wont break the complete job. Please help us sharing your experience and findings. We are stuck on this for a while since there are not much explained about this error over internet.

Yes, we ignore the 116 error by clone 2 command line window, one use to running the script, the other wait for the first process run successfully and doing some simple command like echo Done.
Addition, we add some validation to check the exitcode of the first process, if exitcode is 140 (I return the exitcode of 116 error) and kill the current process by process.exit(0)