PhantomJS exited unexpectedly with exit code -1073741819 - node.js

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?

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!

(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.

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.

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.

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

Related

Yarn / node command "error Command failed with exit code 1." no error

I've got a weird issue going on. I have a node service being started with yarn .... The app seems to work fine for some random amount of time before I get hit with a...
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
There is no error logged. My service already has the following two handlers, but they never log anything when the service dies like this.
process.on('unhandledRejection', (err: any) => {
logger.fatal({ err: err }, 'Process failed. Unhandled Rejection');
});
process.on('uncaughtException', (list) => {
logger.fatal({ err: list }, 'unhandledExceptionThrown');
});
I've read some other SO question (error Command failed with exit code 1. when I try to run yarn) and tried to clear node modules / clean my yarn cache, but so far that has not helped the issue.
Is there something else I can try to track down what's causing the issue?
After lots of digging around, I found something that was able to help move me in the right direction. Im not sure why the handlers above weren't catching the issue, however... when I added --unhandled-rejections=strict to my node command to start the service, the app would blow up as expected and actually would output some useful information.

Jest test Error: Cannot parse /myProj/public/libs/angularjs-datetime-picker/package.json

When running my test which uses jest i get the error given in title.
I have added my public folder in coveragePathIgnorePatterns of jest config but still the same error is being thrown and exit the test with an exitStatus of 1.
if somebody ever runs into this make sure your there are no error in the file. In my case there was a synatax error in the package.json when i removed it everthing started working fine :)

"Process out of memory" error after installing node from source

I'm trying to install NodeJS on shared hosting. I downloaded the source from
https://nodejs.org/en/download/
and followed the usual install procedure with ./config --prefix="$HOME/local".
It compiles without error. However, when I try to run it, I get the following error:
installing /kunden/homepages/32/d690510543/htdocs/local/include/node/zconf.h
installing /kunden/homepages/32/d690510543/htdocs/local/include/node/zlib.h
(uiserver):xxxxxxxx:~/node-v8.11.2$ which node
/kunden/homepages/32/d690510543/htdocs/local/bin/node
(uiserver):xxxxxxxx:~/node-v8.11.2$ node
#
# Fatal error in , line 0
# API fatal error handler returned after process out of memory
#
Illegal instruction
However, I can get the version
$ node -v
v8.11.2
and help.
Nevertheless, I can't run a script
(uiserver):xxxxxxxx:~$ cat hello.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
(uiserver):xxxxxxxx:~$ node hello.js
#
# Fatal error in , line 0
# API fatal error handler returned after process out of memory
#
Illegal instruction
Nor can I enter the REPL:
(uiserver):xxxxxxxx:~$ node -i
#
Fatal error in , line 0
API fatal error handler returned after process out of memory
#
Illegal instruction
I had the same issue and what i realized was that it was only occuring when i use mlab sandbox mongo db.Initially everything was ok even with mlab mongo db but all over sudden i the error started appearing .I changed to locally installed mongodb and all was well,i deleted my mlab mongo db collections and changed back to mlab,all was well again.I guess the issue is with mlab free tier limitations
When I execute my Vue.js project with command:
npm run dev
in webstorm console, the console output:
# Fatal error in , line 0
# API fatal error handler returned after process out of memory
Then when I restart use command:
npm run dev
webstorm crashes, I restart webstorm and use command:
npm run dev
a second time, and it works. So I think it is because that my computer memory is not enough when webstorm starts too many child processes.
Had the same issue (and afaik the same hosting provider). However, installing node through nvm, like described e.g. at https://stackoverflow.com/a/33857377/1680728 did solve the issue for me. I do not know whether its some environment setting or has to do with the fetched binaries/version.
So, I cannot solve the "Process out of memory" error, but I guess the real problem was to have any nodejs version running on a shared host.
I had the same issue and I close my webstorme and try again

gulp-less task exits with zero on invalid styles

Firstly, here is a repo with very simple example of my problem: https://github.com/nkoder/example-of-gulp-less-zero-exit-on-error
I want to define gulp build pipeline which fails on any error. This pipeline would be used in automated process (eg. Continuous Integration) so I need the build command to return non-zero exit code on failure. It works for me with invalid Jade templates or non-passing tests run with Karma.
The problem is when I use gulp-less to prepare CSS from LESS. Whenever I add any pipeline step after gulp-less execution, all errors are "consumed" and the whole task exits with 0. But it shouldn't.
The first question is: How to force wrong task to fail with non-zero exit code? (solved, see answer below)
The second question is: Why error event emitted in less() call followed by piped stream is not making a whole task to return non-zero exit code? Non-zero is returned in some other similar cases, eg. in Jade or ESLint failure. (not solved yet)
Versions:
node 5.11.0
npm 3.8.6
gulp 3.9.1
gulp-less 3.1.0
Listen for the error event and then exit the process explicitly:
gulp.task('wrong', function () {
return gulp
.src('invalid-styles.less')
.pipe(less().on('error', function(error) {
console.log(error.message);
process.exit(1);
}))
.pipe(gulp.dest('generated-styles.css'));
});

How to abort if command fails in Unix shell?

I'm not very great with shell scripting and still couldn't find a solution to this. I want to run a command gulp tslint and if it returns errors, abort the script.
So far I tried gulp tslint || exit 1 with no success. I think it somehow is returning true, even though it has errors when i run it on command prompt e.g.
[12:30:14] Starting 'tslint'...
[12:30:14] Finished 'tslint' after 9.49 ms
[12:30:16] [gulp-tslint] error (quotemark) payment-types.ts[18, 53]: " should be '
How can i make it work?
Any help appreciated. Thanks!
This looks like a gulp question, rather than a shell question. As gulp completes successfully (i.e. reaches an exit without raising an error), it doesn't tell the shell that anything is wrong. The best way to address this is to reconfigure gulp to interpret lint failures as errors.
Could you post your gulpfile.js? Specifically your tslint task.
It probably looks like
gulp.task('tslint', function() {
gulp.src("**/*.ts")
.pipe(tslint.report('prose'))
});
You can instruct your reporter to fail on error by changing this to:
gulp.task('tslint', function() {
gulp.src("**/*.ts")
.pipe(tslint.report('prose', {emitError: true}))
});
edit: look at the gulp-tslint README for more details on emitError

Resources