angular/protractor

Installing/updating webdriver doesn't work in Node 0.11.13

mgol opened this issue · 41 comments

mgol commented
$ node --version
v0.11.13
$ ./node_modules/.bin/webdriver-manager update
Updating selenium standalone
downloading http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar...
Updating chromedriver
downloading https://chromedriver.storage.googleapis.com/2.10/chromedriver_mac32.zip...
chromedriver_2.10.zip downloaded to /Users/mgol/Documents/projects/bn/cbn/repo/polona-gui/node_modules/protractor/selenium/chromedriver_2.10.zip

/Users/mgol/Documents/projects/bn/cbn/repo/polona-gui/node_modules/protractor/node_modules/adm-zip/zipFile.js:66
            throw Utils.Errors.INVALID_FORMAT;
                              ^
Invalid or unsupported zip format. No END header found

EDIT: This is with the newest Protractor 1.0.0-rc1

mgol commented

The problem still exists in Protractor 1.0.0-rc4.

I fixed by downloading selenium from here http://docs.seleniumhq.org/download/,
chromedriver from here http://chromedriver.storage.googleapis.com/index.html

cp selenium-server-standalone-2.42.2.jar /usr/local/lib/node_modules/protractor/selenium
cp chromedriver /usr/local/lib/node_modules/protractor/selenium/

webdriver-manager start

The workaround works for me too. Thanks.

mgol commented

Unfortunately, the error is in the adm-zip package and there hasn't been any new commits in the repo for the last 6 months so it might not be fixed at all.

If nothing changes, Protractor will need to dump (or fork) the package.

I've patched a workaround in chromedriver and submitted a PR here giggio/node-chromedriver#14. not a pure js fix but it solved the problem at $work

Experiencing the same issue after doing a fresh npm install. The downloaded chromedriver_2.10.zip appears to be not in a valid ZIP format:

unzip /Users/dmoore/projects/slideviewer/node_modules/protractor/selenium/chromedriver_2.10.zip
Archive:  /Users/dmoore/projects/slideviewer/node_modules/protractor/selenium/chromedriver_2.10.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /Users/dmoore/projects/slideviewer/node_modules/protractor/selenium/chromedriver_2.10.zip or
        /Users/dmoore/projects/slideviewer/node_modules/protractor/selenium/chromedriver_2.10.zip.zip, and cannot find /Users/dmoore/projects/slideviewer/node_modules/protractor/selenium/chromedriver_2.10.zip.ZIP, period.

@demisx I've been getting that issue intermittently today as well. I think the chromedriver hosting site is flaking out somehow - can you try it again and see if it happens every time?

gitu commented

@juliemr I get the same error; it usually works again after a retry (sometimes it requires multiple ones)
Invalid or unsupported zip format. No END header found webdriver-manager update returned exit code 8action webdriver-manager update failed

@juliemr Yes, I am still getting this Invalid or unsupported zip format. No END header found error with 1.1.x versions of protractor. My temporary solution was downgrading protractor to v1.0.0.

Our build server is also receiving the same error intermittently (but frequently).

mgol commented

Are you all using Node.js 0.11.13? Does it work for you in 0.10.31?

I'm on 0.10.31

on 0.10.31 as well.

mgol commented

Then it's not your issue, you have a different one. My issue concerns Node 0.11.x specifically, everything works fine for me on 0.10.x and it always fails on Node 0.11.13.

@juliemr Would you recommend creating a new GitHub issue for node 0.10.x? The solution is most likely going to be the same for both.

mgol commented

@demisx What solution do you have in mind? Since it works on 0.10 for me and my colleagues and fails on 0.11 on the very same files, the fault must lay in a different place than the files themselves. Unless the solution is to dump adm-zip. ;)

@mzgol Sorry, no solution yet. Upon initial review, It looked to me not node related, since the chromedriver and selenium server zips downloaded by protractor 1.1.x were corrupted on my end. I've figured must've been a protractor dependency issue, since rolling back protractor to 1.0.0 made this problem go away for me. Maybe I am missing something. I'd let @juliemr chime in on this.

gitu commented

@mzgol I'm using 0.10.29 I don't think my problem is connected with the node version

mgol commented

I (sometimes) have the same problem as you all on Node 0.10 & Protractor 1.1.x. I didn't have this problem before, though.

mgol commented

Maybe Protractor should be bundled with Chromedriver & Selenium that work? The update command could still be available but at least we'd have a working starting point.

I think dumping adm-zip might be a good idea, it doesn't look like it's being updated.

The problem with bundling is that Chromedriver & Selenium are OS specific, so the script needs to figure out which one to download. I feel like bundling all of them in would be a bad experience (here, download MBs of stuff!)

mgol commented

The problem with bundling is that Chromedriver & Selenium are OS specific, so the script needs to figure out which one to download

Right, I didn't think about that; bumping the package size so much would be bad, I guess.

Maybe it could be automated that during Protractor installation proper binaries are downloaded (perhaps via a node-gyp script?)

EDIT: That bundling solution won't help in CI scenarios as npm install is there usually invoked on a fresh clone.

Also intermittent errors here, with the following on Travis:

  • node 0.10.31
  • protractor@1.1.1
  • adm-zip@0.4.4

If adm-zip is indeed the culript, why don't we use an alternative ? it seems there are quite a few candidates out there: https://www.npmjs.org/search?q=zip

@juliemr Do you have any idea how to workaround or fix it?

@thalesfsp If you're on a unix like env I’ve dug up an old shell script I’ve used for managing selenium in the past that might help. Just drop it in your project’s ./bin folder, make it executable, and run ./bin/selenium.sh install. See the gist below.

https://gist.github.com/sidwood/fcee60dc7b7e704d818d

mgol commented

@sidwood Your script doesn't work for me:

  Downloading chromedriver archive...
######################################################################## 100.0%
Archive:  chromedriver_mac32.zip
  inflating: chromedriver            
  Downloading selenium server...
                                                                           0.2%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)

I'm on OS X 10.9.4.

EDIT: never mind, it doesn't work only when run through grunt-shell... Thanks for the script!

Looks like node is between you and the script and not liking all the output to stderr. Just run the script directly and it should work just fine, or at the very least let you see whats going on.

On 1 Sep 2014, at 14:39, Michał Gołębiowski notifications@github.com wrote:

@sidwood Your script doesn't work for me:

Downloading chromedriver archive...
######################################################################## 100.0%
Archive: chromedriver_mac32.zip
inflating: chromedriver
Downloading selenium server...
0.2%Warning: stderr maxBuffer exceeded. Use --force to continue.
Error: stderr maxBuffer exceeded.
at Socket. (child_process.js:697:13)
at Socket.emit (events.js:117:20)
at Socket. (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)

Reply to this email directly or view it on GitHub.

mgol commented

If anyone needs to pass it via grunt-shell like me, you need to bump max buffer size. My config:

shell: {
    webdriverUpdate: {
        options: {
            execOptions: {
                maxBuffer: 1024 * 1024 * 64,
            },
        },
        command: './bin/selenium.sh install',
    },
},

This has also happened to me a few times today, but I am running node v0.10.29. After a few attempts it worked, so I think there is something flakey about the server. I wonder if it occasionally fails to send the last few bytes?

@petebacondarwin see #1259. Should be solved with the next release.

mgol commented

So, we're back to the origin. This issue is different from what many here described; #1259 doesn't fix it, the fix will probably require dumping the adm-zip package.

Upgraded to protractor 1.2.0 and passed 12+ builds on Travis CI. It seems solved for me, but I am on nodejs 0.10.31, so that was actually the same issue as @petebacondarwin and not @mzgol's one. Thanks anyway !

Intermittent errors as the rest of the people. +1 to @mzgol as it doesn't resolve the issue.

Just wondering... what exactly makes us think that adm-zip is the culprit here? I hit a very similar issue yesterday with our workaround approach... unable to unzip. Turned out that I had some rogue chromedrivere.exe processes laying about. After killing them, I was able to unzip.

But, even before this, I wasn't able to see anything that really pointed to adm. Thoughts?

I saw that the downloaded driver zip was corrupted, but don't know the adm-zip well enough to tell whether it has anything to do with zipping. Luckily, I haven't encountered this problem since upgrading to protractor 1.2.0.

mgol commented

Luckily, I haven't encountered this problem since upgrading to protractor 1.2.0.

Try Node 0.11.13. ;)

There is the same error with 0.11.14.

The following update to webdriver-manager (~ln 142; code modified from a previously working version of protractor) seemed to fix it for me - can anyone else with the issue confirm?

request(options)
    .on('response', function(response) {
      if (response.statusCode !== 200) {
        fs.unlink(filePath);
        console.error('Error: Got code ' + response.statusCode + ' from ' + fileUrl);
      }
    })
    .on('error', function(error) {
      fs.unlink(filePath);
      console.error('Error: Got error ' + error + ' from ' + fileUrl);
    })
    .on('data', function(data) {
      file.write(data);
    })
    .on('end', function() {
      file.end(function() {
        console.log(fileName + ' downloaded to ' + filePath);
        if (callback) {
          callback(filePath);
        }
      });
    });

Seems due to this issue in request caused by using pipe() while also providing a callback function: request/request#887

Replaced with #1857, which I think tracks the root cause of the remaining issues.

@eviljohnius That fixes it for me. Thanks.

i am also same problem how to fix the problem?