locked
[Bug] WinJS base.js App termination handler crashes VS 2012 RC Ultimate

    Question

  • This method regularly crashes the VS RC.
    terminateAppHandler = function (data) {
            debugger;
            MSApp.terminateApp(data);
        };

    once this code is executed VS crashed and restarts.

    Wednesday, June 13, 2012 1:05 PM

Answers

  • This gets run if there is an unhandled error (which they changed to, by default, to terminate the app). I'm not sure why this is crashing VS, but there are a couple of mitigations:

    1. Catch your errors and deal with them gracefully. Then returning "true" from the error handler will keep the above code from running and closing your app and crashing VS.
    2. You can override the onerror handler for the app to always return true, just make sure you do something about the errors that trickle through there. Here is just some example code that notifies me that I missed a try-catch or async error handler somewhere.
        // Aliases
        var app = WinJS.Application;
    
        // Generic error handler that does not terminate the app.
        app.onerror = function errorHandler(e) {
            appTrace.trace("Unhandled Error", "We failed to catch the following error, file a bug!", true);
            appTrace.traceError(e);
            return true; // We do not want the app to terminate.
        };
    

    Wednesday, June 13, 2012 5:31 PM

All replies

  • I have the same problem!

    Anyone knows how to solve this?

    Thanks!

    Wednesday, June 13, 2012 3:30 PM
  • This gets run if there is an unhandled error (which they changed to, by default, to terminate the app). I'm not sure why this is crashing VS, but there are a couple of mitigations:

    1. Catch your errors and deal with them gracefully. Then returning "true" from the error handler will keep the above code from running and closing your app and crashing VS.
    2. You can override the onerror handler for the app to always return true, just make sure you do something about the errors that trickle through there. Here is just some example code that notifies me that I missed a try-catch or async error handler somewhere.
        // Aliases
        var app = WinJS.Application;
    
        // Generic error handler that does not terminate the app.
        app.onerror = function errorHandler(e) {
            appTrace.trace("Unhandled Error", "We failed to catch the following error, file a bug!", true);
            appTrace.traceError(e);
            return true; // We do not want the app to terminate.
        };
    

    Wednesday, June 13, 2012 5:31 PM
  • What is "appTrace"? It is custom implementation or is in some WinJS/Windows namespace?

    Sunday, July 15, 2012 1:12 PM
  • Thats something Bryan made up (or copied from a MS project) to demonstrate what the error handler function could actually to beside returning "true".

    appTrace is probably a logger, nothing more.

    Monday, July 16, 2012 8:27 AM
  • Yep, it's just a little logging thing.
    Monday, July 16, 2012 4:58 PM