Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

"PhantomJS has crashed" problem when upgrade to PhantomJS 2.1.1 #191

Open
terryyin opened this issue May 13, 2016 · 18 comments
Open

"PhantomJS has crashed" problem when upgrade to PhantomJS 2.1.1 #191

terryyin opened this issue May 13, 2016 · 18 comments

Comments

@terryyin
Copy link

Got problem like

$ bundle exec rake spec:javascript
Running `"/usr/local/bin/phantomjs" "" "/Users/terry/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/jasmine-rails-0.12.4/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "file:///Users/terry/git/less-site/tmp/jasmine/runner.html?spec="`
Running: file:///Users/terry/git/less-site/tmp/jasmine/runner.html?spec=
Starting...
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.

Downgrade PhantomJS to 1.9.8 solved the problem.

@searls
Copy link
Member

searls commented May 13, 2016

Could you create an example project that demonstrates the problem? Perhaps consider pushing a fork of https://github.com/searls/jasmine-rails-exploratory-tests that reproduces the issue?

@jywarren
Copy link

jywarren commented Jun 6, 2016

I'm getting the same or similar error -- though I'm on ARM, not x86. How do I run the tests on the exploratory-tests repository? bundle exec rake spec:javascript gave:

The path /home/warren/sites/jasmine-rails does not exist.

@jywarren
Copy link

jywarren commented Jun 6, 2016

I can't make much of it, but here's my log when i do it with debug=true:

https://gist.github.com/jywarren/c83f582a2c2387cdbfc6925722398881

@mtomov
Copy link

mtomov commented Oct 6, 2016

Same problem on my machine (linux, phantomjs 2.1.1). I think CircleCi experiences same problem

https://gist.github.com/mtomov/b5469ad032bc09cdb833d11fb1751c02

@wenga86
Copy link

wenga86 commented Oct 10, 2016

+1 Same problem, having issues on Mac and Linux. Any updates on this?

Sorry should have read from the command line first.

@zacblazic
Copy link

zacblazic commented Oct 13, 2016

@mtomov: Circle uses 1.9.8 by default which works.

This is a pretty serious issue though, I too have jasmine-rails breaking with phantomjs 2.1.1 (haven't tested other 2.x releases). Platforms: Mac & Linux (Debian).

Will be downgrading to 1.9.8 for now.

@searls
Copy link
Member

searls commented Oct 14, 2016

@zacblazic you can control the version of phantomjs that's used by locking to a specific version of the phantomjs gem, right?

Can anyone on this thread reproduce the issue with an example project? I just spent 30 minutes locally trying to and I couldn't, using PhantomJS 2.1.1 installed via homebrew.

pixeltrix added a commit to alphagov/e-petitions that referenced this issue Oct 16, 2016
Version 0.12.2 exhibited the problem described here:
testdouble/jasmine-rails#191
@jgarber623
Copy link

+1'ing this issue.

On Friday, with PhantomJS 2.1.1 installed via Homebrew and jasmine-rails 0.14.1, my test suite ran without error. Come Monday morning, I start experiencing the PhantomJS crashes reported by @terryyin and others.

My step-by-step to get to a working test suite:

  1. brew uninstall phantomjs
  2. brew tap homebrew/versions
  3. brew install phantomjs198
  4. Reload console/open a new Terminal window/etc. etc.
  5. Update Gemfile: gem 'phantomjs', '~> 1.9' and gem 'jasmine-rails', '~> 0.14.1'
  6. bundle install
  7. Confirm the installed version of the PhantomJS and jasmine-rails gems.
  8. Run rake spec:javascript and 👏.

The above will use a system-level PhantomJS. I didn't try these steps using a version of PhantomJS installed by the gem to ~/.phantomjs so YMMV.

@searls
Copy link
Member

searls commented Oct 17, 2016

Hey @jgarber623 are you able to provide a failing example project? I can't even get to that point

@jgarber623
Copy link

@searls The app and hardware I experienced the issue on are private/employer-managed, so I can't share that code directly. I can see about replicating the problem on other hardware, but that might not necessarily address how the problem (for me, anyway) started over the course of a weekend when my computer sat unused. 🤔

It's a very curious problem, for sure.

(And thanks for jasmine-rails, by the way! 😁 )

@jgarber623
Copy link

@searls Did a bit more digging in on this one and found the actual problem in my code.

In a particular spec file, I had code similar to:

describe('some bit of functionality', function() {
  it('does a thing.', function() {
    //
  });
});

That empty assertion callback was causing PhantomJS 2.1.1 to crash. It did not crash PhantomJS 1.9.8. The takeaway here is that empty describe callback functions appear to be okay (for now), but empty it callback functions should be avoided.

describe('some bit of functionality', function() {
  // this is okay
});

describe('some bit of functionality', function() {
  it('does a thing.', function() {
    // you're in for bad times
  });
});

I'm not sure if this will solve anyone else's problems, but it was the root problem in my codebase.

(Hat tip to @ju-Skinner for his help debugging this one.)

@searls
Copy link
Member

searls commented Oct 18, 2016

@jgarber623 what if the it contains statements other than expect assertions? It only fails when there are no statements in the function?

@jgarber623
Copy link

@searls Ran a couple quick experiments:

describe('some piece of functionality', function() {
  it('crashes PhantomJS.', function() {});
});

describe('some piece of functionality', function() {
  it('crashes PhantomJS.', function() {
    //
  });
});

describe('some piece of functionality', function() {
  it('crashes PhantomJS.', function() {
    'use strict';
  });
});

describe('some piece of functionality', function() {
  it('crashes PhantomJS.', function() {
    var foo = 'bar';
  });
});

describe('some piece of functionality', function() {
  it('is listed as a skipped or pending spec and does not crash PhantomJS.');
});

The top four examples all crash PhantomJS. The last one does not.

@mtomov
Copy link

mtomov commented Oct 19, 2016

I don't have any empty / pending / etc tests in my test suite, but phantomjs still crashes as described.

@caphun
Copy link

caphun commented Nov 9, 2016

I'm on PhantomJS 2.1.1 and jasmine-rails 0.14.1. I was getting the "PhantomJS has crashed" error too with this simple test case:

describe('test', function(){
  it('test', function() {
    expect(null).toEqual(null)
  })
})

However the issue turned out not to be related to the test case itself but some compatibility error in my javascript application code. To see if you have any errors open tmp/jasmine/runner.html file that is generated after every test run and inspect the web console. Once resolved my test runner ran successfully.

@thekindofme
Copy link

In my case the issue was resolved by simply adding the missing () to the end of a method call (it was coffeescript).

- expect( @meter.poll ).toBeFalsy
+ expect( @meter.poll ).toBeFalsy()

@mtomov
Copy link

mtomov commented Jul 3, 2017

I'm pretty sure that this #194 fixed the issue for me. CircleCI also passes with that. Thanks a lot!

@terryyin
Copy link
Author

terryyin commented Jul 4, 2017

After reading lib/assets/javascripts/jasmine-runner.js, I found the problem might partially be fixed by #194, but it also needs the pull request #212 for a couple of bugs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants