12

I run a bunch of Jasmine specs with PhantomJS (via Grunt) on a Windows 7 PC, and I happen to get the following error:

Testing jasmine specs via phantom
......
Running PhantomJS...ERROR
>> 0 [ '' ]
Warning: PhantomJS exited unexpectedly with exit code -1073741819. Use --force to continue.
Aborted due to warnings.

The error does not appear if I delete a bunch of tests; however I have no idea what causes the error.

What I also find strange, it that it only occurs now and then.

Any idea why this happens?

Helge
  • 823
  • 5
  • 13
  • 28

5 Answers5

2

We are running AngularJS tests via jasmine and grunt, and had this very same problem. For us it turned out to be due to our custom $exceptionHandler function.

We were missing the throw exception line that is in the example handler. By not throwing the exception, the test would pass but it would randomly cause PhantomJS to crash.

This means that some of our tests were failing and we didn't know it!

Here's the sample handler from the $exceptionHandler documentation page:

angular.module('exceptionOverride', []).factory('$exceptionHandler', function          () {
  return function (exception, cause) {
    exception.message += ' (caused by "' + cause + '")';
    throw exception; // <--- This is important
  };
});

So I'd look and see if you have custom exception handling too and are possibly missing the throw exception line. I hope it's as simple as that for you too!

Community
  • 1
  • 1
Austin Thompson
  • 2,251
  • 1
  • 17
  • 23
2

(Sadly, I don't have an answer. I would post as a comment, but I don't have the rep.)

I'm getting the same error trying to create html snapshots with grunt-html-snapshot.

Running PhantomJS...ERROR
>> 0 [ '' ]
Warning: PhantomJS exited unexpectedly with exit code -1073741819. Use --force to continue.

Aborted due to warnings.

I'm feeding grunt a list of URLs and I "randomly" get this crash somewhere in the list. I think I have traced it to the child process spawn call that launches phantom.exe with the bridge.js script. It doesn't seem to get as far as trying load the next page before the phantom.exe child process exits with the error. I haven't been able to find any documentation on the error code.

user3233032
  • 116
  • 5
0

I received the same error message as Helge after renaming a folder and running jasmine in grunt.

The folder contained all the JavaScript files I wanted to minify into one file, and I renamed the folder to match the final file name. For example the folder, \src\modules\ was renamed \src\modules.js\.

Removing .js from the folder name solved the problem.

John Clegg
  • 348
  • 3
  • 6
0

Using PhantomJS to generate snapshots for AngularJS.

The snapshots script goes through an array of urls of which it has to take snapshots.

Narrowed down to the possible cause and as it turned out there was a bug in my latest fix in AngularJS. This bug resulted in the constantly switching the home page and the page where the error occurred.

Code Visualization:

$state.go('home state');
...
$state.go('an other state');
...
$state.go('home state');
...
$state.go('an other state');
...
$state.go('home state');
...
...
=> Error: PhantomJS exited unexpectedly with exit code -1073741819

In short:

For me this error was caused by an infinite redirect loop.

bohem.be
  • 1,763
  • 1
  • 15
  • 17
-1

The warning PhantomJS exited unexpectedly with exit code -1073741819 is also displayed when your local PhantomJS is incompatible or corrupt.

With npm list -g phantomjs you can check your PhantomJS version.

If you think that it is corrupt, just reinstall it with:

npm uninstall phantomjs -g
npm install phantomjs -g
Benny Code
  • 51,456
  • 28
  • 233
  • 198