-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Possible Solution] Crash when a Chromium Environment Error occurs on Node Environment #1468
Comments
AFAIK For all possible errors i'm using both node's Sometimes one catches something (syntax, page bugs, simple JS bugs), sometimes other (errors in nodejs objects, if 'error' event is not handled by callbacks). HTML: window.addEventListener('error' ,function(errEvent){
var m
console && console.error(errEvent)
m = 'uncaughtException: ' +
errEvent.message + '\nfilename:"' +
(errEvent.filename ? errEvent.filename : 'app_front.js') +
'", line:' + errEvent.lineno
// show any errors early
document.write('<pre><h2>' +
m + '</h2><div style="color:white;background-color:red">' +
errEvent.error.stack + '</div></pre>'
)
alert(m)
}) nodeJS part: process.on('uncaughtException' ,function(err){
console.error('uncaughtException:', err)
console.error(err.stack)
alert(l10n.uncaughtException + err)
}) have a look here |
@olecom The app crash, is closed by it self, and there is not any clue why. (of course the reason is something wrong in my JS code, and for that I want to see what happen there). This problem occurs when you use nodejs modules, and this modules uses callbacks, you write a callback code in the webkit context, and that callback is executed in node context, when an error occurs there the only one that can catch that error is node, and is nothing is handling the errors on node the app crash without message or dump for that. Apparently the bug appear when you add a Listener to uncaughtException. Normally nothing is listening that, until the developer add a custom listener. I redactor the code to eliminate this NATIVE CODE that is automatically added. // clean exceptions from a previous load (refresh case)
if(process._events.uncaughtException.length > 0){
process._events.uncaughtException.splice(0,1);
}
process.on('uncaughtException', function(e){
console.group('Node uncaughtException');
if(!!e.message){
console.log(e.message);
}
if(!!e.stack){
console.log(e.stack);
}
console.log(e);
console.groupEnd();
});
// Clean Buggy thing
if(process._events.uncaughtException.length > 1
&& !!process._events.uncaughtException[0].toString().match(/native code/)
){
process._events.uncaughtException.splice(0,1);
} This new code is tested on Win7 x64 with nodewebkit 0.8.4 |
Do not log and continue when using http://nodejs.org/api/process.html#process_event_uncaughtexception
|
Further, nedb has an err parameter in most callbacks to indicate if an error was thrown. Consult its documentation. |
@damianb, domains are in a Unstable status. I don't think that can be a solution, a least for the moment. I don't be able to read the error of the nedb callback because the application explode before. // this is executed on webkit environment, directly for a tag script.
var someNODEJSmodule = require('someNODEJSmodule');
someNODEJSmodule.method(function(){
window.inexistentFunction();
}); file in node_modules/someNODEJSmodule.js module.exports = {
method: function(cbk){
cbk();
}
} this is the scenario, that can throw a typeError exception, because the inexistentFunction do not exists. BUT the problem is, that error is throwed on NODE JS ENVIRONMENT, and there is not a handler/catcher/logger/whatever by default in nodewebkit to get that error and show in console or stdout o something. and because of that, the application crash, and close by itself. Is nothing with nedb itself. In order to prevent the crash, you need to define a handler for the uncaughtException in the NODE ENVIRONMENT. The problem with this, is when you do that, something in the nodewebkit code add another handler to that event (uncaughtException) that is BROKEN! and do that the app crash in the same way. |
@danyg "unstable" regarding domains refers to the API's structure (method naming, method availability, etc.). read the documentation on nodejs.org itself again. |
This should be working with latest version now. In 0.13 we changed to an optimized architecture so more features can be supported, see http://nwjs.io/blog/whats-new-in-0.13/ and it's good for keeping up with Chromium upstream -- we released with Node.js v6.0 and new Chromium versions within 1 day after upstream release. The new version would fixed many issues reported here and we're scrubbing them. This issue is closed as we believe it should be fixed. Please leave a message if it isn't and we'll reopen it. |
Hi, I'm creating a proyect that uses NeDB, when I do something like that
And the code on webkit explode because some type error o whatever, the application crash.
I found this solution for that
Apparently the default uncaughtException listener ([native code] says) is not able to handle this type of errors.
To solve this, I remove it doing
process._events.uncaughtException.splice(0,1);
Tested on Windows 7 x64 NodeWebKit 0.8.3
Something interesting is, in this case when the app crash, the app crash report (.dmp file) is not generated.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: