0

I am using exec (promisified) to run a Makefile:

const out = await exec('make', { maxBuffer: 1024 * 1024 * 10 });

However when I take a look at the Makefiles output even when the building was successful the stderr field is always populated.

"stdout": "stuff...",
"stderr": "0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  9 4813k    9  439k    0     0  29.1M      0 --:--:-- --:--:-- --:--:-- 28.6M
100 4813k  100 4813k    0     0   101M      0 --:--:-- --:--:-- --:--:--  100M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 17939  100 17939    0     0  1063k      0 --:--:-- --:--:-- --:--:-- 1094k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 17939  100 17939    0     0  1352k      0 --:--:-- --:--:-- --:--:-- 1459k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 17939  100 17939    0     0  1577k      0 --:--:-- --:--:-- --:--:-- 1751k".

As you can see there my Makefile downloads 4 files at some point. It however populates the stderr field. Also if the file does not download (url incorrect) it just states 0% instead of 100%, which doesn't make things better.

Is there anyway to get only errors in the stderr, it's difficult to get error handling correct when this is happening.

basickarl
  • 37,187
  • 64
  • 214
  • 335
  • Maybe you could some insights on the makefile? What does it do? As such, unclear to me (but maybe this is purely javascript related?) – kebs Jan 12 '18 at 10:22
  • @kebs `curl -o client-dist/documentation/tutorial.pdf $(DOC_URL)`<- That is one of the download lines in the Makefile which well, downloads the file. About if this is a Javascript issue or not I have no idea :/ I'm not sure when Makefile outputs in a normal case and I'm not sure about this in exec in node https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback is causing the issue. – basickarl Jan 12 '18 at 10:27
  • @kebs `The stdout and stderr arguments passed to the callback will contain the stdout and stderr output of the child process. By default, Node.js will decode the output as UTF-8 and pass strings to the callback. The encoding option can be used to specify the character encoding used to decode the stdout and stderr output. If encoding is 'buffer', or an unrecognized character encoding, Buffer objects will be passed to the callback instead.` – basickarl Jan 12 '18 at 10:28
  • Does Makefile normally pass anything to the stderr except errors? – basickarl Jan 12 '18 at 10:29
  • 1
    Well, if you have in the makefile a command that fails, then it may generate output on stderr, no? Does the file content you show look familiar to you ? Can you identify the program that generates it ? (I can't) – kebs Jan 12 '18 at 10:45
  • @kebs Thanks! You got me on the correct path, it was cURL writing to stderr with progress bars. Found the answer here: https://stackoverflow.com/a/18284752/1137669 – basickarl Jan 12 '18 at 11:53

1 Answers1

1

So cURL was writing progress bars to stderr. Found the answer here:

https://stackoverflow.com/a/18284752/1137669

Added the flags --fail --silent --show-error to the cURL command, now it only populates stderr with errors.

basickarl
  • 37,187
  • 64
  • 214
  • 335