sindresorhus / grunt-shell

Run shell commands
MIT License
949 stars 126 forks source link

Error: stderr maxBuffer exceeded #80

Closed mgol closed 10 years ago

mgol commented 10 years ago

I use the following script:

#!/bin/bash

# A modified version of https://gist.github.com/sidwood/fcee60dc7b7e704d818d

set -e

PROTRACTOR_PATH="./node_modules/protractor"
DOWNLOAD_PATH="$PROTRACTOR_PATH/selenium"

CD_VERSION=2.10
CD_URL="http://chromedriver.storage.googleapis.com/$CD_VERSION"
CD_FILE=chromedriver_mac32.zip

SWD_VERSION=2.42
SWD_PATCH=2
SWD_URL="http://selenium-release.storage.googleapis.com/$SWD_VERSION"
SWD_FILE="selenium-server-standalone-$SWD_VERSION.$SWD_PATCH.jar"

# Exit with a given message
abort() {
  printf "\n  \033[31mError: $@\033[0m\n\n" && exit 1
}

# Ensure Protractor is installed
if [ ! -d "$(pwd)/$PROTRACTOR_PATH" ]; then abort "$PROTRACTOR_PATH not found"; fi

# Ensure dependencies are installed
command -v curl > /dev/null 2>&1 || abort "curl is required"
command -v unzip > /dev/null 2>&1 || abort "unzip is required"
command -v java > /dev/null 2>&1 || abort "java is required"

# Install Selenium and chromedriver

mkdir -p "$DOWNLOAD_PATH"
if [ ! -f "${DOWNLOAD_PATH}/chromedriver" ]; then
    cd "$DOWNLOAD_PATH"
    echo "  Downloading chromedriver archive..."
    curl -O --progress-bar "$CD_URL/$CD_FILE"
    unzip "$CD_FILE"
    rm "$CD_FILE"
    cd - >/dev/null
else
    echo "  Chromedriver found"
fi

if [ ! -f "${DOWNLOAD_PATH}/${SWD_FILE}" ]; then
    cd "$DOWNLOAD_PATH"
    echo "  Downloading selenium server..."
    curl -O --progress-bar "$SWD_URL/$SWD_FILE"
    cd - >/dev/null
else
    echo "  Selenium server found"
fi

echo "done!"

When I run it manually via ./bin/webdriver-update, it runs just fine:

$ ./bin/webdriver-update
  Downloading chromedriver archive...
######################################################################## 100.0%
Archive:  chromedriver_mac32.zip
  inflating: chromedriver            
  Downloading selenium server...
######################################################################## 100.0%
done!

but when run via grunt-shell (both 0.7.0 & 1.0.1) I get this:

Running "shell:webdriverUpdate" (shell) task
  Downloading chromedriver archive...
######################################################################## 100.0%
Archive:  chromedriver_mac32.zip
  inflating: chromedriver            
  Downloading selenium server...
                                                                           0.4%Warning: stderr maxBuffer exceeded. Use --force to continue.
Error: stderr maxBuffer exceeded.
    at Socket.<anonymous> (child_process.js:697:13)
    at Socket.emit (events.js:117:20)
    at Socket.<anonymous> (_stream_readable.js:764:14)
    at Socket.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:426:10)
    at emitReadable (_stream_readable.js:422:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
    at Pipe.onread (net.js:528:21)

Aborted due to warnings.

Node 0.10.31, Grunt 0.4.5. grunt-shell config:

shell: {
    bundleInstall: {
        command: 'bundle install',
    },

    webdriverUpdate: {
        command: './bin/webdriver-update',
    },

    removeJenkinsReports: {
        command: 'rm -f test-results{,.*}.xml',
    },
},
mgol commented 10 years ago

Setting the following options:

    webdriverUpdate: {
        options: {
            execOptions: {
                maxBuffer: 1024 * 1024 * 64,
            },
        },
        command: './bin/webdriver-update',
    },

help though it's weird I cannot just route a bash command without specifying additional options.

sindresorhus commented 10 years ago

grunt-shell is best for short running processes as it uses childProcess.exec which buffers the output until the process exits. Try something based on childProcess.spawn like https://www.npmjs.org/search?q=grunt%20spawn